/******************************************************************************

                  版权所有 (C), 2001-2011, 国网电科院通信与用电技术分公司
                  
 ******************************************************************************
  文 件 名   : main.c
  版 本 号   : 初稿
  作    者   : liming
  生成日期   : 2013年4月17日 星期三
  最近修改   :
  功能描述   : 3761和协议适配层测试代码
  函数列表   :
  修改历史   :
  1.日    期   : 2013年4月17日 星期三
    作    者   : liming
    修改内容   : 创建文件

******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <stdarg.h>
#include "con3761adp.h"
#include "fmprint.h"
#include <math.h>


#define PACK_MEM_SIZE  10240
#define OUT_BUF_LEN    10240

#define BUF_LEN_MAX   (1024*1024*50)
UINT8 g_ucPackMem[PACK_MEM_SIZE] = {0}; // 测试封装命令的参数的内存空间
UINT8 g_ucOutBuf[OUT_BUF_LEN]    = {0}; // 存放输出报文
UINT8 g_ucInBuf[OUT_BUF_LEN]     = {0};
UINT8 g_ucOutBufColor[OUT_BUF_LEN]    = {0}; // 存放输出报文

smtPack * getSmtPackPoint()
{
    memset((void*)g_ucPackMem, 0, PACK_MEM_SIZE);
    return (smtPack *)g_ucPackMem;
}

void show_main_name(char *str)
{
      fm_print(str, FR_GREEN|FM_UNDERLINE);
}

void show_sub_name(char * str)
{
    fm_print(str,FR_YELLOW|BK_NORMAL);
}

void show_item_value(char *str)
{
    fm_print(str,FR_WHITE|BK_MAGENTA);
}

void show_error(char *str)
{
     fm_print(str,FR_RED|FM_BOLD|FM_FLASH);
}

void printf_buffer_color(char * pBuf, UINT16 usBufLen)
{

    memset(g_ucOutBufColor, 0,PACK_MEM_SIZE);
    
    if(!pBuf)
    {
       show_error("error print_buffer pointer null!\n");
        return;
    }

    int Len = 0;
    int i = 0;
    Len = (int)usBufLen;
    
    fm_print("pack length is: ", FR_YELLOW|FM_BOLD);
    char buf[10] = {0};
    sprintf(buf,"%d\n\n", Len);
    fm_print(buf,FR_WHITE|BK_MAGENTA|FM_BOLD);
  
    if(Len != 0)
    {       
        for(i = 0; i < Len; i++)
        {   
            memset(buf, 0,10);
            sprintf(buf,"%02X ", (UINT8)pBuf[i]);
            fm_print(buf,FR_WHITE|BK_MAGENTA|FM_BOLD);
        }

        printf("\n\n\n");
    }

}

/*****************************************************************************
 函 数 名  : print_buffer
 功能描述  : 打印报文
 输入参数  : UINT8 * pBuf      
             UINT16* usBufLen  
 输出参数  : 无
 返 回 值  : 
 调用函数  : 
 被调函数  : 
 
 修改历史      :
  1.日    期   : 2013年4月22日 星期一
    作    者   : liming
    修改内容   : 新生成函数

*****************************************************************************/
void print_buffer(UINT8 * pBuf, UINT16* pusBufLen)
{

    if(!pBuf || !pusBufLen)
    {
        printf("error print_buffer pointer null!");
        return;
    }

    int Len = 0;
    int i = 0;
    Len = (int)*pusBufLen;

    printf("pack length is %d\n", Len);
    if(Len != 0)
    {       
        for(i = 0; i < Len; i++)
        {
            printf("%02X ", (UINT8)pBuf[i]);
        }

        printf("\n");
    }

}



void show_mt_error(eMtErr eErr)
{
    char *str = NULL;
    switch(eErr)
    {
        case MT_OK:
        str = "MT_OK 无错误";
        break;

        case MT_ERR_NULL:
        str = "MT_NULL 指针为空";
        break;
        
        case MT_ERR_OUTRNG:
        str = "MT_OUT_RNG 参数越界";
        break;

        case MT_ERR_NONE:
        str = "MT_NONE 不存在,没有找到";
        break;

        case MT_ERR_IO:
        str = "MT_ERR_IO IO错误";
        break;

        case MT_ERR_RES:
        str = "MT_ERR_RES 资源不足";
        break;

        case MT_ERR_INIT:
        str = "MT_ERR_INIT 没有初始化";
        break;
        
        case MT_ERR_PARA:
        str = "MT_ERR_PARA 参数错误";
        break;

        case MT_ERR_FN:
        str = "MT_ERR_FN 指定Afn 中不支持的 Fn";
        break;

        case MT_ERR_PN:
        str = "MT_ERR_PN 指定Afn Fn 中不支持的 Pn";
        break;

        case MT_ERR_ADDR:
        str = "MT_ERR_ADDR 无效地址";
        break;
        
        case MT_ERR_CTRL:
        str = "MT_ERR_CTRL 控制域错误";
        break;

        case MT_ERR_SEQ:
        str = "MT_ERR_SEQ SEQ域错误";
        break;
        
        case MT_ERR_SEQ2CS:
        str = "MT_ERR_SEQ2CS";
        break;

        case MT_ERR_AFN:
        str = "MT_ERR_AFN AFN 错误";
        break;

        case MT_ERR_UNCOMP:
        str = "MT_ERR_UNCOMP 不完整的协议包";
        break;

        case MT_ERR_0x68:
        str = "MT_ERR_0x68 错误的报文起始";
        break;
        
        case MT_ERR_PROTO:
        str = "MT_ERR_PROTO 错误的协议标识";
        break;
        
        case MT_ERR_CS:
        str = "MT_ERR_CS 错误的检测和";
        break;

        case MT_ERR_0x16:
        str = "MT_ERR_0x16 错误的结尾符";
        break;

        case MT_ERR_LOGIC:
        str = "MT_ERR_LOGIC 错误的处理逻辑";
        break;
        
        case MT_ERR_PACK:
        str = "MT_ERR_PACK 不是一个有效的包";
        break;
        case MT_ERR_PFC:
            str = "序列号不对应";
            break;
        case MT_ERR_TIMEOUT:
            str = "报文超时";
            break;
        case MT_ERR_PRM:
            str = "启动方向错误";
            break;

       case MT_ERR_TEAM:
            str = "不属于同一组";
            break;
        case MT_ERR_ENCRYPT:
            str = "加密错误";
            break;
        case MT_ERR_DECRYPT:
            str = "解密错误";
            break;
        default:
        str = "未知错误";
        break;
        
    }


    show_error(str);
    printf("\n");
}


/*扩展协议部分===========================================================================================================================================================================================================================================*/

/* 09 F1    ===========================================================================================================================================================================*/
eMtErr test_pack_afn09f1_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_09_CFIG;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 8;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_9_F1_TML_VERSION;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;



    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0C F4    ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf04_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 8;
    pscmPacket->bAcdFcb = TRUE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F4_TML_UPCOM_STATE;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F150  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af150_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 0;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F150_STATE_CFG;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}/*=====================================================================================================================================================================================*/
/*=====================================================================================================================================================================================*/

/* 0A F604  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af604_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 2;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F604_CON_AGREEMENT;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0A F606  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af606_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F606_CON_ADDRESS;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F607  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af607_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F607_RUN_MODE;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F609  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af609_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F609_SCHEME_TYPE_SETTIN;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F610  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af610_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F610_WORK_PERIOD;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F611  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af611_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F611_TIMEOUT_THR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F612  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af612_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F612_ELEC_THR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F613  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af613_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 8;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F613_UNCOVER_THR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F615  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af615_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 8;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F615_WIRE_JUDGE_THR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F616  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af616_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F616_CLOCK_ERR_THR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F617  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af617_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 8;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F617_LEAK_JUDGE_THR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F618  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af618_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F618_VOL_OUTLIERS_THR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F621  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af621_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F621_CMD_RPS_THR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0A F632  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0af632_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0A_GETP;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 8;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_A_F632_FAUIT_PARAMETER_1;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F601  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf601_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F601_RUN_STATE;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F602  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf602_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F602_METER_PROP;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F604  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf604_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F604_EM_ABNORMAL_ANAL;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F625  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf625_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F625_TOTAL_METER_ABN;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F627  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf627_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F627_CON_FROZEN_STATE;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F628  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf628_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F628_PT_FROZEN_STATE;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F629  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf629_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F629_RESULT_STATISTICS;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F633  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf633_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F633_METER_RUNNING_DATA;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F634  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf634_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F634_ZL_ELEC_OUTLIERS;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F635  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf635_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F635_UNCOVER_OUTLIERS;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F639  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf639_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F639_CLOCK_ERR_DATA;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F640  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf640_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 9;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F640_METER_OUTAGE_DATA;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 0;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F641  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf641_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F641_EM_OCR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F642  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf642_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F642_EM_LOPR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/


/* 0C F643  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf643_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F643_EM_LOFR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/


/* 0C F644  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf644_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F644_EM_PBR;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F645  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf645_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F645_ZFL_LTRO;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F646  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf646_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F646_L10TD_V;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F647  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf647_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F647_L10OD_WM;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F649  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf649_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F649_LVLA_RB;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F650  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf650_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F650_LVLB_RB;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/

/* 0C F651  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0cf651_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;

    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    // sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);

    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0C_ASK1;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;

    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_C_F651_LVLC_RB;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;

    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;

}
/*=====================================================================================================================================================================================*/




/* 0D F161  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df161_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F161_HAVE_FRTH_D;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F625  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df625_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F625_EM_ABN_STATE;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/


/* 0D F632  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df632_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F632_COPY_FAILED_STATIC;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F633  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df633_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F633_RUN_STATE_WORD;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F634  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df634_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F634_LINE_CURRENT_ANAL;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F635  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df635_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F635_OPEN_COVER_DATA;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F639  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df639_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F639_CLOCK_ERROR_DATA;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F652  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df652_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F652_ALL_OVERLOAD_EVENT;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F653  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df653_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F653_PHASEA_OVERLOAD_EVENT;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F654  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df654_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F654_PHASEB_OVERLOAD_EVENT;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/

/* 0D F655  ===========================================================================================================================================================================*/
eMtErr test_pack_afn0df655_m2s()
{
    eCmErr eRet;
    UINT16 usBuflen = 0;
    smtPack* pscmPacket = (smtPack*)g_ucPackMem;


    /* 2 环境初始化 */
    sCmInit  sInit;
    sInit.eRole = MT_ROLE_MASTER;
    //sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eRet = ecm_3761_init(&sInit);
    if (eRet != MT_OK)
    {
        printf("初始化失败\n");
        return eRet;
    }
    char* str = "1234567890123456";
    bCmSetPw(str);


    /* 3 封装参数 */
    memcpy(pscmPacket->sAddress.acRegionCode, "9900", 4);
    pscmPacket->sAddress.usTAddress = 44617;
    pscmPacket->sAddress.bTeamAddr = FALSE;
    pscmPacket->sAddress.ucMAddress = 10;

    pscmPacket->eAFN = AFN_0D_ASK2;
    pscmPacket->eDir = MT_DIR_M2S;
    pscmPacket->ePRM = MT_PRM_ACTIVE;

    pscmPacket->ePos = MT_POS_SIGLE;
    pscmPacket->ucSeq = 4;
    pscmPacket->bAcdFcb = FALSE;


    pscmPacket->usDataNum = 1;
    pscmPacket->sData[0].eCmd = CMD_AFN_D_F655_PHASEC_OVERLOAD_EVENT;
    pscmPacket->sData[0].bApp = FALSE;
    pscmPacket->sData[0].usPN = 1;


    /* 4 调用函数 */
    eRet = emtPack(pscmPacket, &usBuflen, (UINT8*)g_ucOutBuf);
    if (eRet != MT_OK)
    {
        printf("ecm_3761_pack error %d\n", eRet);
        return eRet;
    }

    /* 5 输出结果 */
    printf_buffer_color((char*)g_ucOutBuf, usBuflen);

    return MT_OK;
}
/*=====================================================================================================================================================================================*/



/*扩展协议部分===========================================================================================================================================================================================================================================*/

typedef eMtErr(*ptest_pack)();

typedef struct
{
    int          nTestID;
    ptest_pack   pTest;

}sTestPack;


// 下行测试例表
sTestPack  g_test_pack_down[] = 
{   
    {CMD_AFN_9_F1_TML_VERSION,     test_pack_afn09f1_m2s},

    {CMD_AFN_A_F150_STATE_CFG,          test_pack_afn0af150_m2s},
    {CMD_AFN_A_F604_CON_AGREEMENT,      test_pack_afn0af604_m2s},
    {CMD_AFN_A_F606_CON_ADDRESS,        test_pack_afn0af606_m2s},
    {CMD_AFN_A_F607_RUN_MODE,           test_pack_afn0af607_m2s},
    {CMD_AFN_A_F609_SCHEME_TYPE_SETTIN, test_pack_afn0af609_m2s},
    {CMD_AFN_A_F610_WORK_PERIOD,        test_pack_afn0af610_m2s},
    {CMD_AFN_A_F611_TIMEOUT_THR,        test_pack_afn0af611_m2s},
    {CMD_AFN_A_F612_ELEC_THR,           test_pack_afn0af612_m2s},
    {CMD_AFN_A_F613_UNCOVER_THR,        test_pack_afn0af613_m2s},
    {CMD_AFN_A_F615_WIRE_JUDGE_THR,     test_pack_afn0af615_m2s},
    {CMD_AFN_A_F616_CLOCK_ERR_THR,      test_pack_afn0af616_m2s},
    {CMD_AFN_A_F617_LEAK_JUDGE_THR,     test_pack_afn0af617_m2s},
    {CMD_AFN_A_F618_VOL_OUTLIERS_THR,   test_pack_afn0af618_m2s},
    {CMD_AFN_A_F621_CMD_RPS_THR,        test_pack_afn0af621_m2s},
    {CMD_AFN_A_F632_FAUIT_PARAMETER_1,  test_pack_afn0af632_m2s},
     
    {CMD_AFN_C_F4_TML_UPCOM_STATE,      test_pack_afn0cf04_m2s},
    {CMD_AFN_C_F601_RUN_STATE,          test_pack_afn0cf601_m2s},
    {CMD_AFN_C_F602_METER_PROP,         test_pack_afn0cf602_m2s},
    {CMD_AFN_C_F604_EM_ABNORMAL_ANAL,   test_pack_afn0cf604_m2s},
    {CMD_AFN_C_F625_TOTAL_METER_ABN,    test_pack_afn0cf625_m2s},
    {CMD_AFN_C_F627_CON_FROZEN_STATE,   test_pack_afn0cf627_m2s},
    {CMD_AFN_C_F628_PT_FROZEN_STATE,    test_pack_afn0cf628_m2s},
    {CMD_AFN_C_F629_RESULT_STATISTICS,  test_pack_afn0cf629_m2s},
    {CMD_AFN_C_F633_METER_RUNNING_DATA, test_pack_afn0cf633_m2s},
    {CMD_AFN_C_F634_ZL_ELEC_OUTLIERS,   test_pack_afn0cf634_m2s},
    {CMD_AFN_C_F635_UNCOVER_OUTLIERS,   test_pack_afn0cf635_m2s},
    {CMD_AFN_C_F639_CLOCK_ERR_DATA,     test_pack_afn0cf639_m2s},
    {CMD_AFN_C_F640_METER_OUTAGE_DATA,  test_pack_afn0cf640_m2s},
    {CMD_AFN_C_F641_EM_OCR,             test_pack_afn0cf641_m2s},
    {CMD_AFN_C_F642_EM_LOPR,            test_pack_afn0cf642_m2s},
    {CMD_AFN_C_F643_EM_LOFR,            test_pack_afn0cf643_m2s},
    {CMD_AFN_C_F644_EM_PBR,             test_pack_afn0cf644_m2s},
    {CMD_AFN_C_F645_ZFL_LTRO,           test_pack_afn0cf645_m2s},
    {CMD_AFN_C_F646_L10TD_V,            test_pack_afn0cf646_m2s},
    {CMD_AFN_C_F647_L10OD_WM,           test_pack_afn0cf647_m2s},
    {CMD_AFN_C_F649_LVLA_RB,            test_pack_afn0cf649_m2s},
    {CMD_AFN_C_F650_LVLB_RB,            test_pack_afn0cf650_m2s},
    {CMD_AFN_C_F651_LVLC_RB,            test_pack_afn0cf651_m2s},

    {CMD_AFN_D_F161_HAVE_FRTH_D,           test_pack_afn0df161_m2s},
    {CMD_AFN_D_F625_EM_ABN_STATE,          test_pack_afn0df625_m2s },
    {CMD_AFN_D_F632_COPY_FAILED_STATIC,    test_pack_afn0df632_m2s },
    {CMD_AFN_D_F633_RUN_STATE_WORD,        test_pack_afn0df633_m2s },
    {CMD_AFN_D_F634_LINE_CURRENT_ANAL,     test_pack_afn0df634_m2s },
    {CMD_AFN_D_F635_OPEN_COVER_DATA,       test_pack_afn0df635_m2s },
    {CMD_AFN_D_F639_CLOCK_ERROR_DATA,      test_pack_afn0df639_m2s },
    {CMD_AFN_D_F652_ALL_OVERLOAD_EVENT,    test_pack_afn0df652_m2s },
    {CMD_AFN_D_F653_PHASEA_OVERLOAD_EVENT, test_pack_afn0df653_m2s },
    {CMD_AFN_D_F654_PHASEB_OVERLOAD_EVENT, test_pack_afn0df654_m2s },
    {CMD_AFN_D_F655_PHASEC_OVERLOAD_EVENT, test_pack_afn0df655_m2s },

    {0xFFFF, NULL}
    
};

// 上行测试例表
sTestPack  g_test_pack[] =
{
    {0xFFFF, NULL}    
};

/*****************************************************************************
 函 数 名  : test_pack
 功能描述  : 测试封装帧功能-测试例 入口 上行
 输入参数  : int i  
 输出参数  : 无
 返 回 值  : 
 调用函数  : 
 被调函数  : 
 
 修改历史      :
  1.日    期   : 2013年4月22日 星期一
    作    者   : liming
    修改内容   : 新生成函数

*****************************************************************************/
void test_pack(int iTest)
{
    ptest_pack   pTest;
    int i = 0;
    int count = 0;
    eMtErr eRet = MT_OK;
    count = sizeof(g_test_pack)/sizeof(sTestPack);
    

    for(i = 0; i < count; i++)
    {
        if(g_test_pack[i].nTestID == iTest)
        {
            pTest = g_test_pack[i].pTest;
            
            if(pTest!= NULL)
            {
                eRet = pTest();
                if(eRet != MT_OK)
                {
                    show_mt_error(eRet);
                }
            }
            
            return;
        }
    }
   
  
show_error("尚不支持的命令\n");
}

/*****************************************************************************
 函 数 名  : test_pack_down
 功能描述  : 测试封装帧功能-测试例 入口 下行
 输入参数  : int i  
 输出参数  : 无
 返 回 值  : 
 调用函数  : 
 被调函数  : 
 
 修改历史      :
  1.日    期   : 2013年4月22日 星期一
    作    者   : liming
    修改内容   : 新生成函数

*****************************************************************************/
void test_pack_down(int iTest)
{
    ptest_pack   pTest;
    int i = 0;
    int count = 0;
    eMtErr eRet = MT_OK;
    count = sizeof(g_test_pack_down)/sizeof(sTestPack);
    

    for(i = 0; i < count; i++)
    {
        if(g_test_pack_down[i].nTestID == iTest)
        {
            pTest = g_test_pack_down[i].pTest;
            
            if(pTest!= NULL)
            {
                eRet = pTest();
                if(eRet != MT_OK)
                {
                    show_mt_error(eRet);
                }
            }
            
            return;
        }
    }
   
    show_error("尚不支持的命令\n");
}

void print_td_d(sMtTd_d *psTd_d)
{
    if(psTd_d)
    {
        printf("Td_d = %02d/%02d/%02d", 
            psTd_d->sT.ucYY,
            psTd_d->sT.ucMM,
            psTd_d->sT.ucDD);
    }
}

void show_app_sub_data(eMtDir eDir,eMtCmd emtCmd, uMtApp *puAppData)     //字符对应
{
    int     i   = 0;
    int     j   = 0;
    eMtErr eRet = MT_OK;
    eMtErr eRet2 = MT_OK;

    sMtCmdInfor sCmdInfo;
    eMtCmd   eCmd = CMD_AFN_F_UNKOWN;
    char *pStr = NULL;
    
    switch(emtCmd)
    {
        case CMD_AFN_0_F3_ONE_BY_ONE:
        {
            sMtOnebyOne * psOnebyOne = (sMtOnebyOne*)puAppData;
            printf("afn = %d\n", psOnebyOne->eAFN);
            printf("Num = %d\n", psOnebyOne->ucNum);
            int i = 0;
            for(i = 0; i < psOnebyOne->ucNum; i++)
            {
                printf("%d:\n", i+1);
                printf("确认命令  = %04X ", psOnebyOne->sOne[i].eCmd);
                eRet = eMtGetCmdInfor(psOnebyOne->sOne[i].eCmd, MT_DIR_S2M, &sCmdInfo);
                
                
                if(MT_OK == eRet)
                {
                   pStr =  sCmdInfo.pName; 
                }
                else
                {
                    eRet2 = eMtGetCmdInfor(psOnebyOne->sOne[i].eCmd, MT_DIR_M2S, &sCmdInfo);
                    if(eRet2 == MT_OK)
                    {
                        pStr =  sCmdInfo.pName; 
                    }
                    else
                    {
                        pStr = "未知命令";
                    }
                }

                show_item_value(pStr);
                //printf("%s\n", pStr);

                printf("\n测量点号  = %d\n", psOnebyOne->sOne[i].usPn);
                printf("确认结果  = %s\n", psOnebyOne->sOne[i].bOk == TRUE ? "确认" : "否认");
            }
            
            
        }
        break;


        case CMD_AFN_4_F1_TML_UP_CFG:
        {
            sMtTmlUpCfg * psTmlUpCfg = (sMtTmlUpCfg*)puAppData;

            printf("ucRTS = %d\n", psTmlUpCfg->ucRTS);
            printf("ucRTM = %d\n", psTmlUpCfg->ucRTM);
            printf("ucReSendTimes = %d\n", psTmlUpCfg->ucReSendTimes);
            printf("ucHeartBeat = %d\n", psTmlUpCfg->ucHeartBeat);
            printf("usTmWaitTimeoutS = %d\n", psTmlUpCfg->usTmWaitTimeoutS);
            printf("bAutoReportAsk_1 = %s\n", psTmlUpCfg->bAutoReportAsk_1 == TRUE ? "true":"false");
            printf("bAutoReportAsk_2 = %s\n", psTmlUpCfg->bAutoReportAsk_2 == TRUE ? "true":"false");
            printf("bAutoReportAsk_3 = %s\n", psTmlUpCfg->bAutoReportAsk_3 == TRUE ? "true":"false");
        }
        break;


        case CMD_AFN_4_F10_TML_POWER_CFG:
        {
            sMtTmlPowerCfg * pData = (sMtTmlPowerCfg*)puAppData;
            char addr[13] = {0};
            char pwd[7] = {0};
            
            printf("usNum = %d\n", pData->usNum);
            for(i = 0; i < pData->usNum; i++)
            {
                printf("---------num %d:--------------\n", i+1);
                printf("busMeterID = %s\n", pData->sOne[i].busMeterID == TRUE ? "true":"false");
                printf("busPn = %s\n", pData->sOne[i].busPn == TRUE ? "true":"false");
                printf("bsBaudPort = %s\n", pData->sOne[i].bsBaudPort == TRUE ? "true":"false");
                printf("beProto = %s\n", pData->sOne[i].beProto == TRUE ? "true":"false");
                printf("bacMeterAddr = %s\n", pData->sOne[i].bacMeterAddr == TRUE ? "true":"false");
                printf("bacPwd = %s\n", pData->sOne[i].bacPwd == TRUE ? "true":"false");
                printf("bucPayRateNum = %s\n", pData->sOne[i].bucPayRateNum == TRUE ? "true":"false");
                printf("bsDigit = %s\n", pData->sOne[i].bsDigit == TRUE ? "true":"false");
                printf("bacGathrAddr = %s\n", pData->sOne[i].bacGathrAddr == TRUE ? "true":"false");
                printf("bsUserClass = %s\n", pData->sOne[i].bsUserClass == TRUE ? "true":"false");


                printf("Data:\n");
                printf("usMeterID = %d\n", pData->sOne[i].usMeterID);
                printf("usPn = %d\n", pData->sOne[i].usPn);
                printf("sBaudPort.eBaudRate = %d\n", pData->sOne[i].sBaudPort.eBaudRate);
                printf("sBaudPort.ucPort = %d\n", pData->sOne[i].sBaudPort.ucPort);
                printf("eProto = %d\n", pData->sOne[i].eProto);

                memcpy(addr, pData->sOne[i].acMeterAddr, 12);
                printf("acMeterAddr = %s\n",addr);
                memcpy(pwd,pData->sOne[i].acPwd, 6);
                printf("acPwd = %s\n",pwd);

                printf("ucPayRateNum = %d\n", pData->sOne[i].ucPayRateNum);
                
                printf("sDigit.ucInteger = %d\n", pData->sOne[i].sDigit.ucInteger);
                printf("sDigit.ucDecimal = %d\n", pData->sOne[i].sDigit.ucDecimal);
                memcpy(addr, pData->sOne[i].acGathrAddr, 12);
                printf("acMeterAddr = %s\n",addr);
                
                printf("sUserClass.ucBig = %d\n", pData->sOne[i].sUserClass.ucBig);
                printf("sUserClass.ucSmall = %d\n", pData->sOne[i].sUserClass.ucSmall);
              

                
            }

           
        }

        break;

        case CMD_AFN_A_F10_TML_POWER_CFG:
        {
            sMtTmlPowerCfg_Q* pData = (sMtTmlPowerCfg_Q*)puAppData;

            printf("usN = %d\n", pData->usN);
            for(i = 0; i < pData->usN; i++)
            {
               printf("usID[%d] = %d\n",i+1,  pData->usID[i]);
              
            }
        }
        break;
                
        case CMD_AFN_4_F38_CFG_ASK_1:
        {
            sMtAsk1Cfg * pData = (sMtAsk1Cfg*)puAppData;

            printf("ucBig = %d\n", pData->ucBig);
            printf("ucM = %d\n", pData->ucM);
            for(i = 0; i < pData->ucM; i++)
            {
               printf("sOne[%d] ucSmall = %d\n",i,  pData->sOne[i].ucSmall);
               printf("sOne[%d] ucFN = %d\n",i,  pData->sOne[i].ucFN);
               for(j = 0; j < pData->sOne[i].ucFN; j++)
               {
                  eCmd = pData->sOne[i].eCmd[j];
                  printf("sOne[%d] eCmd[%d] = 0x%04X\t",i, j, eCmd);
                  eRet = eMtGetCmdInfor(eCmd, MT_DIR_M2S, &sCmdInfo);
                  if(eRet == MT_OK)
                  {
                     printf("%s\n", sCmdInfo.pName);
                  }
                  else
                  {
                     printf("unknown\n");
                  }
               }
            }
        }
        break;

        case CMD_AFN_4_F39_CFG_ASK_2:
        {
            sMtAsk2Cfg * pData = (sMtAsk2Cfg*)puAppData;

            printf("ucBig = %d\n", pData->ucBig);
            printf("ucM = %d\n", pData->ucM);
            for(i = 0; i < pData->ucM; i++)
            {
               printf("sOne[%d] ucSmall = %d\n",i,  pData->sOne[i].ucSmall);
               printf("sOne[%d] ucFN = %d\n",i,  pData->sOne[i].ucFN);
               for(j = 0; j < pData->sOne[i].ucFN; j++)
               {
                  eCmd = pData->sOne[i].eCmd[j];
                  printf("sOne[%d] eCmd[%d] = 0x%04X\t",i, j, eCmd);
                  eRet = eMtGetCmdInfor(eCmd, MT_DIR_M2S, &sCmdInfo);
                  if(eRet == MT_OK)
                  {
                     printf("%s\n", sCmdInfo.pName);
                  }
                  else
                  {
                     printf("unknown\n");
                  }
               }
            }
        }
        break;
        
        case CMD_AFN_A_F38_CFG_ASK_1:
        case CMD_AFN_A_F39_CFG_ASK_2:
        {
            sMtAsk1Cfg_Q* pData = (sMtAsk1Cfg_Q*)puAppData;

            printf("ucBig = %d\n", pData->ucBig);
            printf("ucN = %d\n", pData->ucN);
            for(i = 0; i < pData->ucN; i++)
            {
               printf("ucSmall[%d] = %d\n",i,  pData->ucSmall[i]);
            
            }
        }
        break;
        
        case CMD_AFN_4_F65_CFG_AUTO_1:
        case CMD_AFN_4_F66_CFG_AUTO_2:
        case CMD_AFN_A_F65_CFG_AUTO_1:
        case CMD_AFN_A_F66_CFG_AUTO_2:
        {
            sMtCfgAuto_1 * pData = (sMtCfgAuto_1*)puAppData;
            switch(pData->eUnit)
            {
                case MT_RPT_mm:
                   pStr = "MT_RPT_mm 分钟";
                   break;
               case MT_RPT_HH:
                   pStr = "MT_RPT_HH 小时";
                    break;
                case MT_RPT_DD:
                   pStr = "MT_RPT_DD 天";
                   break;
               case MT_RPT_MM:
                   pStr = "MT_RPT_MM 月";
                    break;    
                default:
                    pStr = "MT_RPT_UNKOWN 不知";
                            break;
            }

            

            printf("eUnit    = %s\n", pStr);
            printf("ucPeriod = %d\n", pData->ucPeriod);
            printf("sTime    = %02d年%02d月%02d日 星期%02d %02d:%02d:%02d\n", 
                    pData->sTime.ucYear,
                    pData->sTime.ucMonth,
                    pData->sTime.ucDay, 
                    pData->sTime.ucWeek,
                    pData->sTime.ucHour,
                    pData->sTime.ucMinute,
                    pData->sTime.ucSecond);
            printf("ucR = %d\n", pData->ucR);
            printf("ucN = %d\n", pData->ucN);
            for(i = 0; i < pData->ucN; i++)
            {
                  printf("sOne[%d] usPn:%d  ",i, pData->sCmdPn[i].usPn);
                 
                  eCmd = pData->sCmdPn[i].eCmd;
                  printf("eCmd:0x%04X\t", eCmd);
                  eRet = eMtGetCmdInfor(eCmd, MT_DIR_M2S, &sCmdInfo);
                  if(eRet == MT_OK)
                  {
                     printf("%s\n", sCmdInfo.pName);
                  }
                  else
                  {
                     printf("unknown\n");
                  } 
            }           
        }
        break;
        
        case CMD_AFN_4_F67_GOP_AUTO_1:
        case CMD_AFN_4_F68_GOP_AUTO_2:    
        case CMD_AFN_A_F67_GOP_AUTO_1:
        case CMD_AFN_A_F68_GOP_AUTO_2:
        {
            sMtGopAuto_1 * pData = (sMtGopAuto_1*)puAppData;
            switch(pData->eGo)
            {
                case MT_AUTO_GO:
                   pStr = "启动";
                   break;
               case MT_AUTO_STOP:
                   pStr = "停止";
                    break;
             
                default:
                    pStr = " 不知";
                            break;
            }

            printf("eGo = %s\n", pStr);
                  
        }
        break;
        case CMD_AFN_4_F150_STATE_CFG:
        case CMD_AFN_A_F150_STATE_CFG:
        {
            sMtValidIdentification* pData = (sMtValidIdentification*)puAppData;

            for( i = 0; i < 256; i++){
                for(  j = 0; j < 8; j++){
                    if(pData->eIdentification_0[i].eMeasPointSta_0[j]  == TRUE) printf("%d:有效\n", (i) * 8 + j);
                }
            }
        }
        break;

        case CMD_AFN_4_F604_CON_AGREEMENT:
        case CMD_AFN_A_F604_CON_AGREEMENT:
        {
            sMtConAgreement* pData = (sMtConAgreement*)puAppData;
            switch (pData->eWork)
            {
            case MT_TM:
                pStr = "台区管理单元";
                break;
            default:
                pStr = " 未知";
                break;
            }
            printf("管理单元工作类型为  %s\n", pStr);
            
            switch (pData->eAgreement)
            {
            case MT_GW3761:
                pStr = "国网13761协议";
                break;
            case MT_OOP:
                pStr = "oop协议";
                break;
            default:
                pStr = " 未知协议";
                break;
            }
            printf("下装终端通信协议类型：%s\n", pStr);
        }
        break;

        case CMD_AFN_4_F606_CON_ADDRESS:
        case CMD_AFN_A_F606_CON_ADDRESS:
        {
            sMtConAddress* pData = (sMtConAddress*)puAppData;
            printf("集中器逻辑地址：%02x %02x %02x %02x %02x %02x", pData->eAdress1, pData->eAdress2, pData->eAdress3, pData->eAdress4, pData->eAdress5, pData->eAdress6);
        }
        break;

        case CMD_AFN_4_F607_RUN_MODE:
        case CMD_AFN_A_F607_RUN_MODE:
        {
            sMtRunMode* pData = (sMtRunMode*)puAppData;
            switch (pData->eRead)
            {
            case 0x00:
                pStr = "连接终端";
                break;
            case 0x01:
                pStr = "连接电能表";
                break;
            case 0x02:
                pStr = "不连接下装设备";
                break;
            default:
                pStr = "未知抄表方式";
                break;
            }
            printf("抄表方式：%s\n", pStr);
            printf("档案读取方案号：%d\n", pData->eFileRead);
            switch (pData->eValid)
            {
            case 0xAA:
                pStr = "有效";
                break;
            default:
                pStr = "无效";
                break;
            }
            printf("交采有效开关：%s\n", pStr);
            switch (pData->eDetect)
            {
            case 0xAA:
                pStr = "有效";
                break;
            default:
                pStr = "无效";
                break;
            }
            printf("掉电事件保持探测开关：%s\n", pStr);
            switch (pData->eSave)
            {
            case 0xAA:
                pStr = "有效";
                break;
            default:
                pStr = "无效";
                break;
            }
            printf("停电异常数据存储开关：%s\n", pStr);
            switch (pData->eFactoryMode)
            {
            case 0x00:
                pStr = "不判断";
                break;
            case 0xFF:
                pStr = "不判断";
                break;
            case 0x01:
                pStr = "广东南网光一";
                break;
            default:
                pStr = "错误";
                break;
            }
            printf("厂家模式：%s\n", pStr);
            switch (pData->eDeal)
            {
            case 0xAA:
                pStr = "开启";
                break;
            default:
                pStr = "关闭";
                break;
            }
            printf("未知电能表作为单相表处理：%s\n", pStr);
            switch (pData->eNoJudege)
            {
            case 0xAA:
                pStr = "开启";
                break;
            default:
                pStr = "关闭";
                break;
            }
            printf("日冻结穿透抄读开关：%s\n", pStr);
            printf("台区区分管理开关：\n");
            if (pData->eManagement & 0x01)
            {
                pStr = "补抄任务开启";
            }
            else
            {
                pStr = "补抄任务未开启";
            }
            printf("\t%s\n", pStr);
            if (pData->eManagement & 0x02)
            {
                pStr = "时钟跳变判断开启";
            }
            else
            {
                pStr = "时钟跳变判断未开启";
            }
            printf("\t%s\n", pStr);
            if (pData->eManagement & 0x04)
            {
                pStr = "掉电事件两次判断开启";
            }
            else
            {
                pStr = "掉电事件两次判断未开启";
            }
            printf("\t%s\n", pStr);
            if (pData->eManagement & 0x08)
            {
                pStr = "掉电事件采集最近10次开启";
            }
            else
            {
                pStr = "掉电事件采集最近10次未开启";
            }
            printf("\t%s\n", pStr);
        }
        break;

        case CMD_AFN_4_F609_SCHEME_TYPE_SETTIN:
        case CMD_AFN_A_F609_SCHEME_TYPE_SETTIN:
        {
            sMtTypeSettin* pData = (sMtTypeSettin*)puAppData;
            switch (pData->usGeneral)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("总分析:%s\n", pStr);
            switch (pData->usTime)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("特定时段分析:%s\n", pStr);
            switch (pData->usDaily)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("日曲线分析:%s\n", pStr);
            switch (pData->usPhase)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("分相分析:%s\n", pStr);
            switch (pData->usAbnormal)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("电能表异常用电情况分析（解释：零火线、开表盖、接线、三相表失压失流断相、逆相序）:%s\n", pStr);
            switch (pData->usAttribution)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("台区归属分析:%s\n", pStr);
            switch (pData->usClockMonitoring)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("电能表时钟监测:%s\n", pStr);
            switch (pData->usClockProofreading)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("电能表时钟校对:%s\n", pStr);
            switch (pData->usLoadCurve)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("三相表负荷曲线:%s\n", pStr);
            switch (pData->usPhaseBreakingState)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("单相表失压断相状态分析:%s\n", pStr);
            switch (pData->usMetrologicalFault)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("计量故障监测分析（解释：停走飞走倒走）:%s\n", pStr);
            switch (pData->usPowerOffTime)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("电能表掉电时间监测:%s\n", pStr);
            switch (pData->usDingxinTerminalLineLoss)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("读取鼎信终端线损数据:%s\n", pStr);
            switch (pData->usTerminalFourRatesLiuquan)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("读取终端四率六全:%s\n", pStr);
            switch (pData->usLeakageJudgment)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("火零线漏电判断:%s\n", pStr);
            switch (pData->us14LoadReading)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("单相表14负荷抄读:%s\n", pStr);
            switch (pData->usZoneResultCopy)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("台区区分结果抄读:%s\n", pStr);
            switch (pData->usV)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("电压分析:%s\n", pStr);
            switch (pData->usCloseTable)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("关闭三相表失压失流断相分析:%s\n", pStr);
            switch (pData->usSearchTable)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("搜表结果读取:%s\n", pStr);
            switch (pData->usOvercurrentCollection)
            {
            case 1:
                pStr = "开启";
                break;
            case 0:
                pStr = "关闭";
                break;
            default:
                pStr = "未知";
                break;
            }
            printf("过流事件采集:%s\n", pStr);

        }
        break;

        case CMD_AFN_4_F610_WORK_PERIOD:
        case CMD_AFN_A_F610_WORK_PERIOD:
        {
            sMtAfn04F610* pData = (sMtAfn04F610*)puAppData;
            printf("允许抄表时间：\n");
            for (i = 0; i < 3; i++) {
                for (j = 0; j < 8; j++) {
                    if (pData->eWorkPeriod[i].bWorkTime[j] == TRUE) printf("%d点\n", i * 8 + j);
                }
            }
            /*printf("特定监控时段：\n");
            for (i = 0; i < 3; i++) {
                for (j = 0; j < 8; j++) {
                    if (pData->eSpecMonitor[i].bSpecMonitor[j] == TRUE) printf("%d点\n", i * 8 + j);
                }
            }*/
        }
        break;

        case CMD_AFN_4_F611_TIMEOUT_THR:
        case CMD_AFN_A_F611_TIMEOUT_THR:
        {
            sMtTimeoutThr* pData = (sMtTimeoutThr*)puAppData;
            if (pData->eInterval == 0xFF)
                printf("下行通信数据帧间隔：%d ms\n",100);
            else
                printf("下行通信数据帧间隔：%d ms\n", pData->eInterval);
            if (pData->eComTimeout == 0xFF)
                printf("下行通信超时时间：%d s\n", 10);
            else
                printf("下行通信超时时间：%d s\n", pData->eComTimeout);
            if (pData->e485Timeout == 0xFF)
                printf("485抄读超时时间：%d s\n", 10);
            else
                printf("485抄读超时时间：%d s\n", pData->e485Timeout);
            if (pData->eCarTimeout == 0xFF)
                printf("载波抄读超时时间：%d s\n", 100);
            else
                printf("载波抄读超时时间：%d s\n", pData->eCarTimeout);
            if (pData->eFailNum == 0xFF)
                printf("下行通信允许通信失败次数：%d 次\n", 10);
            else
                printf("下行通信允许通信失败次数：%d 次\n", pData->eFailNum);
            if (pData->eCutNum == 0xFF)
                printf("抄表任务超时切表次数：%d 次\n", 2);
            else
                printf("抄表任务超时切表次数：%d 次\n", pData->eCutNum);
            if (pData->eAllowNum == 0xFF)
                printf("抄表任务允许连续抄表超时次数：%d 次\n", 5);
            else
                printf("抄表任务允许连续抄表超时次数：%d 次\n", pData->eAllowNum);
            if (pData->eAllowTotalNum == 0xFF)
                printf("抄表任务允许累计抄表超时次数：%d 次\n", 15);
            else
                printf("抄表任务允许累计抄表超时次数：%d 次\n", pData->eAllowTotalNum);
            if (pData->eUnvalidNum == 0xFF)
                printf("零火线任务允许累计抄读无效次数：%d 次\n", 12);
            else
                printf("零火线任务允许累计抄读无效次数：%d 次\n", pData->eUnvalidNum);
            if (pData->e485Extra == 0xFF)
                printf("485抄读额外帧间间隔时间：%d s\n", 2);
            else
                printf("485抄读额外帧间间隔时间：%d s\n", pData->e485Extra);
            if (pData->eCarExtra == 0xFF)
                printf("载波抄读额外帧间间隔时间：%d s\n", 5);
            else
                printf("载波抄读额外帧间间隔时间：%d s\n", pData->eCarExtra);
            if (pData->eForbidTime == 0xFF)
                printf("抄表时段每小时禁止抄读时间：%d min\n", 0);
            else
                printf("抄表时段每小时禁止抄读时间：%d min\n", pData->eForbidTime);
            if (pData->ePointNum == 0xFF)
                printf("档案读取测量点点数：%d 个\n", 20);
            else
                printf("档案读取测量点点数：%d 个\n", pData->ePointNum);
            printf("台区区分管理开关：\n");
            if (pData->eThrMp & 0x01)
            {
                pStr = "下行数据帧间隔倍率*10倍";
            }
            else
            {
                pStr = "下行数据帧间隔无倍率";
            }
            printf("\t%s\n", pStr);
            if (pData->eThrMp & 0x02)
            {
                pStr = "下行通信超时时长倍率*10倍";
            }
            else
            {
                pStr = "下行通信超时时长无倍率";
            }
            printf("\t%s\n", pStr);
            if (pData->eThrMp & 0x04)
            {
                pStr = "485超时倍率*10倍";
            }
            else
            {
                pStr = "485超时无倍率";
            }
            printf("\t%s\n", pStr);
            if (pData->eThrMp & 0x08)
            {
                pStr = "载波超时倍率*10倍";
            }
            else
            {
                pStr = "载波超时无倍率";
            }
            printf("\t%s\n", pStr);
            switch (pData->eReadThr)
            {
            case 0xAA:
                pStr = "开启";
                break;
            default:
                pStr = "关闭";
                break;
            }
            printf("是否开启测量点读取门限：%s\n", pStr);
            if(pData->eThrValue > 2000)
                printf("测量点读取门限值：%d\n",248);
            else
                printf("测量点读取门限值：%d\n", pData->eThrValue);
        }
        break;

        case CMD_AFN_4_F612_ELEC_THR:
        case CMD_AFN_A_F612_ELEC_THR:
        {
            
            sElecThr* pData = (sElecThr*)puAppData;
            (pData->WireCur<1000.000&&pData->WireCur>-1000.000)?printf("最低火线电流绝对值：%.3f\n", pData->WireCur):printf("最低火线电流绝对值：超出范围\n");
            (pData->ZeroCur<1000.000&&pData->ZeroCur>-1000.000)?printf("最低零线电流绝对值：%.3f\n", pData->ZeroCur):printf("最低零线电流绝对值：超出范围\n");
            (pData->ZlDv<1000.000&&pData->ZlDv>-1000.000)?printf("最低零火线电流绝对值差值：%.3f\n", pData->ZlDv):printf("最低零火线电流绝对值差值：超出范围\n");
            (pData->ZlRate<1000.000)?printf("最低零火线电流比值：%.2f\n", pData->ZlRate):printf("最低零火线电流比值：超出范围\n");
            (pData->ActivePower<10000.0000)?printf("最低日正向有功电量：%.4f\n", pData->ActivePower):printf("最低日正向有功电量：超出范围\n");
            printf("最低有效抄读次数：%d 次\n", pData->ReadNum);
        }
        break;

        case CMD_AFN_4_F613_UNCOVER_THR:
        case CMD_AFN_A_F613_UNCOVER_THR:
        {
            sMtUncoverThr* pData = (sMtUncoverThr*)puAppData;
            printf("开表盖累计时间：%d\n", pData->eUncoverTotalTime);
            printf("开表盖抄读时间：%d\n", pData->eUncoverReadTime);
        }
        break;

        case CMD_AFN_4_F615_WIRE_JUDGE_THR:
        case CMD_AFN_A_F615_WIRE_JUDGE_THR:
        {
            sMtAfn04F615* pData = (sMtAfn04F615*)puAppData;
            printf("正向电能量门限：%.4f\n", pData->dForwardPowerThr);
            printf("反向电能量门限：%.4f\n", pData->dReversePowerThr);
        }
        break;

        case CMD_AFN_4_F616_CLOCK_ERR_THR:
        case CMD_AFN_A_F616_CLOCK_ERR_THR:
        {
            sMtAfn04f616* pData = (sMtAfn04f616*)puAppData;
            printf("时钟误差：%d s\n", pData->ClockErr);
        }
        break;

        case CMD_AFN_4_F617_LEAK_JUDGE_THR:
        case CMD_AFN_A_F617_LEAK_JUDGE_THR:
        {
            sMtAfn04F617* pData = (sMtAfn04F617*)puAppData;
            printf("最低火线电流绝对值：%.4f\n", pData->fMinFW);
            printf("最低火零线电流绝对值差值：%.4f\n", pData->fMinFNDiff);
            printf("最低火零线电流比值：%.2f\n", pData->fMinFNRate);
            printf("连续零线电流为零个数门限：%02x\n", pData->uNetrualZeroThr);
            printf("最底有效抄读次数：%02x\n", pData->uMinValidCopy);
            printf("最底无效抄读次数：%02x\n", pData->uMinUnValidCopy);
        }
        break;

        case CMD_AFN_4_F618_VOL_OUTLIERS_THR:
        case CMD_AFN_A_F618_VOL_OUTLIERS_THR:
        {
            sMtAfn04f618* pData = (sMtAfn04f618*)puAppData;
            (pData->OvervoltageThr<1000.0)?printf("电压过压门限：%.1f\n", pData->OvervoltageThr):printf("电压过压门限：超出范围\n");
            (pData->DecompressionThr<1000.0)?printf("电压失压门限：%.1f\n", pData->DecompressionThr):printf("电压失压门限：超出范围\n");
            (pData->ReversePowerThr<10000.0000)?printf("光伏表反向电量门限：%.4f\n", pData->ReversePowerThr):printf("光伏表反向电量门限：超出范围\n");
        }
        break;

        case CMD_AFN_4_F621_CMD_RPS_THR:
        case CMD_AFN_A_F621_CMD_RPS_THR:
        {
            sMtAfn04f621* pData = (sMtAfn04f621*)puAppData;
            printf("接线类型判断最少有效负荷记录数据点数：%d\n", pData->usN);
            (pData->VoltageJudgeThr<1000.0)?printf("电压有效点判断门限：%.1f（±百分比）\n", pData->VoltageJudgeThr):printf("电压有效点判断门限：超出范围（±百分比）\n");
            (pData->ElectricJudgeThr<1000.000&&pData->ElectricJudgeThr>-1000.000)?printf("电流有效点判断门限：%.3f A\n", pData->ElectricJudgeThr):printf("电流有效点判断门限：超出范围 A\n");
            printf("电流接线判断最低有效点个数：%d 个\n", pData->ValidNum);
            (pData->ElectricRatio<1000.0)?printf("电流分布统计比率：%.1f %\n", pData->ElectricRatio):printf("电流分布统计比率：超出范围 %\n");

        }
        break;
        
        case CMD_AFN_4_F632_FAUIT_PARAMETER_1:
        case CMD_AFN_A_F632_FAUIT_PARAMETER_1:
        {
            sMtFauitParameter* pData = (sMtFauitParameter*)puAppData;
            if (pData->usCTWF != 0xFF) {
                printf("电能表无冻结连续时间门限:%d 日\n", pData->usCTWF);
            }
            else {
                printf("电能表无冻结连续时间门限:未知\n");
            }
            if (pData->usNFEETOEM != 0xFFFF) {
                printf("能表无冻结电能量门限:%02X.%02X kWh\n", pData->usNFEETOEM >> 8, pData->usNFEETOEM & 0x0F);
            }
            else {
                printf("能表无冻结电能量门限:N/A kWh\n");
            }
            if (pData->usSCTOWHM != -866.665f) {
                printf("电能表停走电流门限:%3.3f A\n", pData->usSCTOWHM);
            }
            else {
                printf("电能表停走电流门限:N/A A\n");
            }
            if (pData->usRCTTOWHM != 0xFF) {
                printf("电能表倒走连续时间门限:%d 日\n", pData->usRCTTOWHM);
            }
            else {
                printf("电能表倒走连续时间门限:未知\n");
            }
            if (pData->usEETFBWOWHM != 0xFFFF) {
                printf("电能表倒走电能量门限:%02x.%02x kWh\n", pData->usEETFBWOWHM >> 8, pData->usEETFBWOWHM & 0x0F);
            }
            else {
                printf("电能表倒走电能量门限:N/A kWh\n");
            }
            if (pData->usEETOSPMFAFWHM != 0xFFFF && pData->usEETOSPMFAFWHM0 != 0xFF) {
                printf("电能表飞走单相表电能量门限:%X.%02X kWh\n", pData->usEETOSPMFAFWHM, pData->usEETOSPMFAFWHM0);
            }
            else {
                printf("电能表飞走单相表电能量门限:N/A kWh\n");
            }
            if (pData->usWHMFATPMEET != 0xFFFF && pData->usWHMFATPMEET != 0xFF) {
                printf("电能表飞走三相表电能量门限:%X.%02X kWh\n", pData->usWHMFATPMEET, pData->usWHMFATPMEET);
            }
            else {
                printf("电能表飞走三相表电能量门限:N/A kWh\n");
            }
            if (pData->usETOUEEIOWHM != 0xFFFF) {
                printf("电能表电能示值不平误差门限:%02X.%02X kWh\n", pData->usETOUEEIOWHM >> 8, pData->usETOUEEIOWHM & 0x0F);
            }
            else {
                printf("电能表电能示值不平误差门限:N/A kWh\n");
            }
        }
        break;


        case CMD_AFN_C_F25_POWER_RATE_CUR:
        {
            sMtCurPQUI * pData = (sMtCurPQUI*)puAppData;
            //char addr[13] = {0};
           // char pwd[7] = {0};


            printf("bsReadTime = %s\n", pData->bsReadTime == TRUE ? "true":"false");
            printf("bfP = %s\n", pData->bfP == TRUE ? "true":"false");
            printf("bfPa = %s\n", pData->bfPa == TRUE ? "true":"false");
            printf("bfPb = %s\n", pData->bfPb == TRUE ? "true":"false");
            printf("bfPc = %s\n", pData->bfPc == TRUE ? "true":"false");
            
            printf("bfQ = %s\n", pData->bfQ == TRUE ? "true":"false");
            printf("bfQa = %s\n", pData->bfQa == TRUE ? "true":"false");
            printf("bfQb = %s\n", pData->bfQb == TRUE ? "true":"false");
            printf("bfQc = %s\n", pData->bfQc == TRUE ? "true":"false");
            
            printf("bfPf = %s\n", pData->bfPf == TRUE ? "true":"false");
            printf("bfPfa = %s\n", pData->bfPfa == TRUE ? "true":"false");
            printf("bfPfb = %s\n", pData->bfPfb == TRUE ? "true":"false");
            printf("bfPfc = %s\n", pData->bfPfc == TRUE ? "true":"false");
            
            printf("bfUa = %s\n", pData->bfUa == TRUE ? "true":"false");
            printf("bfUb = %s\n", pData->bfUb == TRUE ? "true":"false");
            printf("bfUc = %s\n", pData->bfUc == TRUE ? "true":"false");
            
            printf("bfIa = %s\n", pData->bfIa == TRUE ? "true":"false");
            printf("bfIb = %s\n", pData->bfIb == TRUE ? "true":"false");
            printf("bfIc = %s\n", pData->bfIc == TRUE ? "true":"false");
            printf("bfI0 = %s\n", pData->bfI0 == TRUE ? "true":"false");
     

            printf("bfS = %s\n", pData->bfS == TRUE ? "true":"false");
            printf("bfSa = %s\n", pData->bfSa == TRUE ? "true":"false");
            printf("bfSb = %s\n", pData->bfSb == TRUE ? "true":"false");
            printf("bfSc = %s\n", pData->bfSc == TRUE ? "true":"false");


            //data
            printf("bsReadTime\n");
            printf("YY= %d\n", pData->sReadTime.ucYY);
            printf("MM= %d\n", pData->sReadTime.ucMM);
            printf("DD= %d\n", pData->sReadTime.ucDD);
            printf("HH= %d\n", pData->sReadTime.ucHH);
            printf("mm= %d\n", pData->sReadTime.ucmm);

            //
            printf("fP = %f\n", pData->fP);
            printf("fPa = %f\n", pData->fPa);
            printf("fPb = %f\n", pData->fPb);
            printf("fPc = %f\n", pData->fPc);
            
            printf("fQ = %f\n", pData->fQ);
            printf("fQa = %f\n", pData->fQa);
            printf("fQb = %f\n", pData->fQb);
            printf("fQc = %f\n", pData->fQc);

            printf("fPf = %f\n", pData->fPf);
            printf("fPfa = %f\n", pData->fPfa);
            printf("fPfb = %f\n", pData->fPfb);
            printf("fPfc = %f\n", pData->fPfc);

            printf("fUa = %f\n", pData->fUa);
            printf("fUb = %f\n", pData->fUb);
            printf("fUc = %f\n", pData->fUc);

            printf("fIa = %f\n", pData->fIa);
            printf("fIb = %f\n", pData->fIb);
            printf("fIc = %f\n", pData->fIc);
            printf("fI0 = %f\n", pData->fI0);
          
            printf("fS = %f\n", pData->fS);
            printf("fSa = %f\n", pData->fSa);
            printf("fSb = %f\n", pData->fSb);
            printf("fSc = %f\n", pData->fSc);

        }
        break;




        case CMD_AFN_5_F31_CHECK_TIME:
        {
            sMtUserClock * pData = (sMtUserClock*)puAppData;
            printf("check time :\n");
            printf("ucYear : %d\n", pData->ucYear);
            printf("ucMonth : %d\n", pData->ucMonth);
            printf("ucWeek : %d\n", pData->ucWeek);
            printf("ucDay : %d\n", pData->ucDay);
            printf("ucHour : %d\n", pData->ucHour);
            printf("ucMinute : %d\n", pData->ucMinute);
            printf("ucSecond : %d\n", pData->ucSecond);

            
        }
        break;


        case CMD_AFN_9_F1_TML_VERSION:
        {   
            char buf[12] = {0};
            sMtTmlVersion * pData = (sMtTmlVersion*)puAppData;

            memcpy(buf, pData->ucFactoryID, 4);
            printf("厂商代号：%s\n", buf);
            
            memset(buf, 0x00, sizeof(buf));
            memcpy(buf, pData->ucDeviceID, 8);
            printf("设备编号：%s\n", buf);

            memset(buf, 0x00, sizeof(buf));
            memcpy(buf, pData->ucSoftwareID, 4);
            printf("终端版本号：%s\n", buf);

            memcpy(buf, pData->ucInfoCodeCap, 11);
            printf("终端配置容量信息码：%s\n", buf);
            
            memset(buf, 0x00, sizeof(buf));
            memcpy(buf, pData->ucProtolID, 8);
            printf("终端通信规约版本号：%s\n", buf);

            memset(buf, 0x00, sizeof(buf));
            memcpy(buf, pData->ucHardWareID, 4);
            printf("终端硬件版本号：%s\n", buf);

            printf("sDateSoftware:\t");
            printf("%d年%d月%d日\n", pData->sDateSoftware.ucYY,
                                     pData->sDateSoftware.ucMM,
                                     pData->sDateSoftware.ucDD);

            printf("sDateHardware:\t");
            printf("%d年%d月%d日\n", pData->sDateHardware.ucYY,
                                      pData->sDateHardware.ucMM,
                                      pData->sDateHardware.ucDD);
            
        }
        break;
            


        case CMD_AFN_9_F2_TML_INPUT_OUT:
        {
            sMtTmlInputOut * pData = (sMtTmlInputOut*)puAppData;
            printf("ucPulseInputNum = %d\n",  pData->ucPulseInputNum);
            printf("ucSwitchInputNum = %d\n",  pData->ucSwitchInputNum);
            printf("ucDcNum = %d\n",  pData->ucDcNum);
            printf("ucSwitchOutputNum = %d\n",  pData->ucSwitchOutputNum);
            printf("usReadMeterNum = %d\n",  pData->usReadMeterNum);
            
            printf("usTmlRecvBuf = %d\n",  pData->usTmlRecvBuf);
            printf("usTmlSendBuf = %d\n",  pData->usTmlSendBuf);
            
            printf("sMacAddr = %d-%d-%d-%d-%d-%d\n",  pData->sMacAddr.ucMac[0],
                                                    pData->sMacAddr.ucMac[1],
                                                    pData->sMacAddr.ucMac[2],
                                                    pData->sMacAddr.ucMac[3],
                                                    pData->sMacAddr.ucMac[4],
                                                    pData->sMacAddr.ucMac[5]);
            printf("ucPortNum = %d\n",  pData->ucPortNum);

            for(i = 0; i < pData->ucPortNum; i++)
            {
                printf("port[%d]:\n", i + 1);
                printf("ucPort = %d\n",  pData->sPort[i].ucPort);


                printf("eInter = ");
                switch(pData->sPort[i].eInter)
                {
                    case MT_INTER_RS485:
                        printf("MT_INTER_RS485\n");
                        break;

                    case MT_INTER_RS232:
                        printf("MT_INTER_RS232\n");
                        break;
                        
                    case MT_INTER_SERIW:
                        printf("MT_INTER_SERIW\n");
                        break;

                    default:
                        printf("unkown eInterType\n");
                        break;

                }
                
                printf("bStandard = %s\n",  pData->sPort[i].bStandard == TRUE ? "true" : "false");

                 printf("eUse = ");
                switch(pData->sPort[i].eUse)
                {
                    case MT_PORR_USE_EXP:
                        printf("MT_PORR_USE_EXP\n");
                        break;

                    case MT_PORR_USE_CNG:
                        printf("MT_PORR_USE_CNG\n");
                        break;
                        
                    case MT_PORR_USE_GTH:
                        printf("MT_PORR_USE_GTH\n");
                        break;
                        
                    case MT_PORR_USE_SHR:
                        printf("MT_PORR_USE_SHR\n");
                        break;

                    default:
                        printf("unkown eUse\n");
                        break;

                }

                
                printf("ulBaud = %d\n",  pData->sPort[i].ulBaud);
                printf("usDevNum = %d\n",  pData->sPort[i].usDevNum);
                printf("usRecvBuf = %d\n",  pData->sPort[i].usRecvBuf);
                printf("usSendBuf = %d\n",  pData->sPort[i].usSendBuf);

            }

        }
        break;

        case CMD_AFN_9_F3_TML_OTHER_CFG:
            {
                sMtTmlOtherCfg * pData = (sMtTmlOtherCfg*)puAppData;
                printf("usMp = %d\n", pData->usMp);
                printf("ucGroup = %d\n", pData->ucGroup);
                printf("ucTask = %d\n", pData->ucTask);
                printf("ucTeam = %d\n", pData->ucTeam);
                printf("eFrezMp = %d\n", pData->eFrezMp);
                printf("eFrezP = %d\n", pData->eFrezP);
                printf("eFrezQ = %d\n", pData->eFrezQ);
                printf("eFrezPt = %d\n", pData->eFrezPt);
                printf("eFrezQt = %d\n", pData->eFrezQt);
                printf("ucDay = %d\n", pData->ucDay);
                printf("ucMonth = %d\n", pData->ucMonth);
                printf("ucPCtrl = %d\n", pData->ucPCtrl);
                printf("ucHarm = %d\n", pData->ucHarm);
                printf("ucCapa = %d\n", pData->ucCapa);
                printf("ucVip = %d\n", pData->ucVip);
                for(i = 0; i < 16; i++)
                {
                    printf("bBig[%d] = %s\n",i, pData->bBig[i] == TRUE ? "true" : "false");
                }
                
                for(i = 0; i < 16; i++)
                {
                    printf("ucSmall[%d] = %d\n",i, pData->ucSmall[i]);
                }


            }

            break;


            case CMD_AFN_9_F4_SUPPORT_PARA_CFG:
            {    
                sMtCmdInfor    sCmdInfo = {0};
                sMtSuptParaCfg * pData = (sMtSuptParaCfg*)puAppData;
                printf("support cfg num = %d\n", pData->ucNum);
                for(i = 0; i < pData->ucNum; i++)
                {
                    printf("%d: cmd = 0x%04X\t", i+1, pData->eCfgCmd[i]);
                    eRet = eMtGetCmdInfor(pData->eCfgCmd[i], MT_DIR_M2S, &sCmdInfo);  
                    if(MT_OK == eRet)
                    {
                        printf("%s\n", sCmdInfo.pName);
                    }
                    else
                    {
                       printf("错误的命令字\n");
                    }

                }

            }

            break;
            
            case CMD_AFN_9_F5_SUPPORT_CTRL_CFG:
            {    
                sMtCmdInfor    sCmdInfo = {0};
                sMtSuptCtrlCfg * pData = (sMtSuptCtrlCfg*)puAppData;
                printf("support cfg num = %d\n", pData->ucNum);
                for(i = 0; i < pData->ucNum; i++)
                {
                    printf("%d: cmd = 0x%04X\t", i+1, pData->eCfgCmd[i]);
                    eRet = eMtGetCmdInfor(pData->eCfgCmd[i], MT_DIR_M2S, &sCmdInfo);  
                    if(MT_OK == eRet)
                    {
                        printf("%s\n", sCmdInfo.pName);
                    }
                    else
                    {
                       printf("错误的命令字\n");
                    }
                }
            }

            break;
            
            case CMD_AFN_9_F6_SUPPORT_ASK1_CFG:
            {    
                sMtCmdInfor    sCmdInfo = {0};
                sMtSuptAsk1 * pData = (sMtSuptAsk1*)puAppData;
                printf("support cfg num = %d\n", pData->ucNum);
                for(i = 0; i < pData->ucNum; i++)
                {
                    printf("%d: cmd = 0x%04X\t", i+1, pData->eCfgCmd[i]);
                    eRet = eMtGetCmdInfor(pData->eCfgCmd[i], MT_DIR_M2S, &sCmdInfo);  
                    if(MT_OK == eRet)
                    {
                        printf("%s\n", sCmdInfo.pName);
                    }
                    else
                    {
                       printf("错误的命令字\n");
                    }
                }
            }

            break;

            case CMD_AFN_9_F7_SUPPORT_ASK2_CFG:
            {    
                sMtCmdInfor    sCmdInfo = {0};
                sMtSuptAsk2 * pData = (sMtSuptAsk2*)puAppData;
                printf("support cfg num = %d\n", pData->ucNum);
                for(i = 0; i < pData->ucNum; i++)
                {
                    printf("%d: cmd = 0x%04X\t", i+1, pData->eCfgCmd[i]);
                    eRet = eMtGetCmdInfor(pData->eCfgCmd[i], MT_DIR_M2S, &sCmdInfo);  
                    if(MT_OK == eRet)
                    {
                        printf("%s\n", sCmdInfo.pName);
                    }
                    else
                    {
                       printf("错误的命令字\n");
                    }
                }
            }

            break;

            case CMD_AFN_9_F8_SUPPORT_EVNT_CFG:
               {    
                    sMtSuptEvent * pData = (sMtSuptEvent*)puAppData;
                    printf("support event num = %d\n", pData->ucNum);
                    char *pStr = NULL;
                    for(i = 0; i < pData->ucNum; i++)
                    {
                        printf("%d: event =  %d", i+1, pData->eErc[i]);
                        switch(pData->eErc[i])
                        {
                            case MT_ERC_1_INIT:
                                pStr = "ERC1：数据初始化和版本变更记录";
                                break;

                            case MT_ERC_2_PARA_LOSS:
                                pStr = "ERC2：参数丢失记录";
                                break;


                            case MT_ERC_3_PARA_MODIFY:
                                pStr = "ERC3：参数变更记录";
                                break;

                            case MT_ERC_4_STATE_CHANGE:
                                pStr = "ERC4：状态量变位记录";
                                break;

                            case MT_ERC_5_REMOTE_SWITCH:
                                pStr = "ERC5：遥控跳闸记录";
                                break;

                            case MT_ERC_6_PCTRL_SWITCH:
                                pStr = "ERC6：功控跳闸记录";
                                break;
                                
                            case MT_ERC_7_ECTRL_SWITCH:
                                pStr = "ERC7：电控跳闸记录";
                                break;

                            case MT_ERC_8_METER_CHANGE:
                                pStr = "ERC8：电能表参数变更";
                                break;                    

                            case MT_ERC_9_ELEC_EXCP:
                                pStr = "ERC9：电流回路异常";
                                break;

                            case MT_ERC_10_VOLT_EXCP:
                                pStr = "ERC10：电压回路异常";
                                break;

                            case MT_ERC_11_PHASE_EXCP:
                                pStr = "ERC11：相序异常";
                                break;

                            case MT_ERC_12_METER_TIME:
                                pStr = "ERC12：电能表时间超差";
                                break;

                            case MT_ERC_13_METER_FAULT:
                                pStr = "ERC13：电表故障信息";
                                break;

                            case MT_ERC_14_TML_ON_OFF:
                                pStr = "ERC14：终端停/上电事件";
                                break;

                            case MT_ERC_15_HARM_OVER:
                                pStr = "ERC15：谐波越限告警";
                                break;

                            case MT_ERC_16_DC_OVER:
                                pStr = "ERC16：直流模拟量越限记录";
                                break;

                            case MT_ERC_17_UNBL_OVER:
                                pStr = "ERC17：电压/电流不平衡度越限记录";
                                break;

                            case MT_ERC_18_CAPA_LOCK:
                                pStr = "ERC18：电容器投切自锁记录";
                                break;

                            case MT_ERC_19_BUY_PARA:
                                pStr = "ERC19：购电参数设置记录";
                                break;

                            case MT_ERC_20_AUTH_ERROR:
                                pStr = "ERC20：消息认证错误记录";
                                break;
                                
                            case MT_ERC_21_TML_FAULT:
                                pStr = "ERC21：终端故障记录";
                                break;

                            case MT_ERC_22_HAVE_OVER:
                                pStr = "ERC22：有功总电能量差动越限事件记录";
                                break;

                            case MT_ERC_23_ECTRL_WARN:
                                pStr = "ERC23：电控告警事件记录";
                                break;

                            case MT_ERC_24_VOLT_OVER:
                                pStr = "ERC24：电压越限记录";
                                break;

                            case MT_ERC_25_ELEC_OVER:
                                pStr = "ERC25：电流越限记录";
                                break;

                            case MT_ERC_26_SP_OVER:
                                pStr = "ERC26：视在功率越限记录";
                                break;
                                
                            case MT_ERC_27_POWER_DOWN:
                                pStr = "ERC27：电能表示度下降记录";
                                break;

                            case MT_ERC_28_POWER_OVER:
                                pStr = "ERC28：电能量超差记录";
                                break;

                            case MT_ERC_29_METER_FLY:
                                pStr = "ERC29：电能表飞走记录";
                                break;

                            case MT_ERC_30_METER_STOP:
                                pStr = "ERC30：电能表停走记录";
                                break;

                            case MT_ERC_31_READ_FAULT:
                                pStr = "ERC31：终端485抄表失败事件记录";
                                break;
                                
                            case MT_ERC_32_FLOW_OVER:
                                pStr = "ERC32：终端与主站通信流量超门限事件记录";
                                break;      


                            case MT_ERC_33_METER_WORD:
                                pStr = "ERC33：电能表运行状态字变位事件记录";
                                break;

                            case MT_ERC_34_CT_EXCP:
                                pStr = "ERC34：CT异常事件记录";
                                break;
                                
                            case MT_ERC_35_UNKOWN:
                                pStr = "ERC35：发现未知电表事件记录";
                                break;      

                        default:
                            pStr = "错误的事件记录类型";
                            break;

                        }

                     printf("  %s\n", pStr);  
                    }
                }

                break;
        
            case CMD_AFN_C_F2_TML_CLOCK:
            {
                sMtUserClock * psTmlClock = (sMtUserClock*)puAppData;
                printf("%d年%d月%d日\n",psTmlClock->ucYear,psTmlClock->ucMonth,psTmlClock->ucDay);
                printf("星期 %d \n",psTmlClock->ucWeek);
                printf("%d时%d分%d秒\n",psTmlClock->ucHour,psTmlClock->ucMinute,psTmlClock->ucSecond);
            }
            break;
            
            case CMD_AFN_C_F3_TML_PARA_STATE:
            {
                sMtAfn0cF03 * psTmlClock = (sMtAfn0cF03*)puAppData;
                UINT16  i;
                for(i = 0; i < MT_TERMINAL_STATUS_USER_MAX;i++)
                {
                    printf("stat[%d]  = %d\n",i+1,psTmlClock->bParaStatus[i]);
                }
            }
            break;

            case CMD_AFN_C_F4_TML_UPCOM_STATE:
            {
                sMtAfn0cF04 * psUpComStat = (sMtAfn0cF04*)puAppData;
                printf("主动上报: %s\n",psUpComStat->bUp ? "允许" : "禁止");
                printf("通话: %s\n",psUpComStat->bCom ? "允许" : "禁止");
            }
            break;
            
            case CMD_AFN_C_F5_TML_CTRL_SET:
            {
                sMtAfn0cF05 * psCtrlSet = (sMtAfn0cF05*)puAppData;
                INT32   i,j;
                printf("保电投入状态: %s\n",psCtrlSet->bRemain ? "允许" : "禁止");
                printf("剔除投入状态: %s\n",psCtrlSet->bDelete ? "允许" : "禁止");
                printf("催费投入状态: %s\n",psCtrlSet->bPayWarn ? "允许" : "禁止");

                for ( i = 0 ;i < MT_AFN0CF05_MAXGROUPS;i++)
                {
                    printf("***********************************************************\n");
                    printf("总加组%d: %s\n",i+1,psCtrlSet->bGroup[i] ? "有效" : "无效");
                    if (psCtrlSet->bGroup[i])
                    {
                        printf("总加组%d: 功能定值方案号 %d\n\n",i+1,psCtrlSet->sGroup[i].ucScheme);
                        for (j = 0; j < 8;j++)
                        {
                            printf("总加组%d: 功能时段 %d %s\n",i+1,j+1,psCtrlSet->sGroup[i].bPowerCtrl[j] ? 
                            "有效":"无效");
                        }
                        printf("\n");
                        printf("总加组%d: 时段控 %s\n",i+1,psCtrlSet->sGroup[i].bTimeCtrl ? "有效":"无效");
                        printf("总加组%d: 厂休控 %s\n",i+1,psCtrlSet->sGroup[i].bRestCtrl ? "有效":"无效");
                        printf("总加组%d: 营业报停控 %s\n",i+1,psCtrlSet->sGroup[i].bStopCtrl ? "有效":"无效");
                        printf("总加组%d: 当前功率下浮控 %s\n\n",i+1,psCtrlSet->sGroup[i].bDownCtrl ? "有效":"无效");
                        printf("总加组%d: 月电控 %s\n",i+1,psCtrlSet->sGroup[i].bMonthCtrl ? "有效":"无效");
                        printf("总加组%d: 购电控 %s\n\n",i+1,psCtrlSet->sGroup[i].bBuyCtrl ? "有效":"无效");
                        for (j = 0; j < 8;j++)
                        {
                            printf("总加组%d: 功率轮次 %d %s\n",i+1,j+1,psCtrlSet->sGroup[i].bPowerTimeSta[j] ? 
                            "受控":"不受控");
                        }
                        printf("\n");
                        for (j = 0; j < 8;j++)
                        {
                            printf("总加组%d: 电控轮次 %d %s\n",i+1,j+1,psCtrlSet->sGroup[i].bElecTimeSta[j] ? 
                            "受控":"不受控");
                        }
                    }
                }
            }
            break;

            case CMD_AFN_C_F6_TML_CTRL_STATE:
            {
                sMtAfn0cF06 * psAfn0cF06 = (sMtAfn0cF06*)puAppData;
                INT32   i,j;

                for ( i = 8; i < 8; i++)
                {
                    printf("终端 %d: %s状态\n",i+1,psAfn0cF06->bTrip[i] ? "跳闸" : "合闸");
                }
                printf("\n");
                printf("当前终端 %s催费告警状态\n\n",(psAfn0cF06->ucPayWarn == MT_AFN0CF06_PAYWARNING_ENABLE) ? "处于" : "未处于");
                
                for ( i = 0 ;i < 8;i++)
                {
                    printf("***********************************************************\n");
                    printf("总加组%d: %s\n",i+1,psAfn0cF06->bGroup[i] ? "有效" : "无效");
                    if (psAfn0cF06->bGroup[i])
                    {
                        printf("当前功率定值: %0.1f\n\n",psAfn0cF06->sGroup[i].fCurPower);

                        printf("浮动方向:");
                        switch(psAfn0cF06->sGroup[i].sPowerDrift.eDir)
                        {
                        case MT_FLOAT_DIR_UP:
                            printf(" 上浮\n\n");
                            break;
                        case MT_FLOAT_DIR_DOWN:
                            printf(" 下浮\n\n");
                            break;
                        case MT_FLOAT_DIR_UNKOWN:
                            printf(" 未知浮动方向\n\n");
                            break;
                        default:
                            printf(" 数值错误\n\n"); 
                        }

                        printf("浮动系数:%d\n",psAfn0cF06->sGroup[i].sPowerDrift.ucValue);
                        printf("________________________________________________________\n");
                        for(j = 0; j < 8;j++ )
                        {
                            printf("终端 %d: %s功控跳闸状态\n\n",j+1,psAfn0cF06->sGroup[i].bPowerOutSta[j] ? "处于" : "未处于");
                        }
                        printf("________________________________________________________\n");
                        for(j = 0; j < 8;j++ )
                        {
                            printf("终端 %d: %s月电控跳闸状态\n\n",j+1,psAfn0cF06->sGroup[i].bMonthElecOutSta[j] ? "处于" : "未处于");
                        }
                        printf("________________________________________________________\n");
                        for(j = 0; j < 8;j++ )
                        {
                            printf("终端 %d: %s购电控跳闸状态\n\n",j+1,psAfn0cF06->sGroup[i].bBuyElecOutSta[j] ? "处于" : "未处于");
                        }
                        printf("________________________________________________________\n");
                        printf("终端%s时段控越限告警状态\n\n",psAfn0cF06->sGroup[i].bTimeCtrlSta ? "处于":"未处于");
                        printf("终端%s厂休控越限告警状态\n\n",psAfn0cF06->sGroup[i].bRestCtrlSta ? "处于":"未处于");
                        printf("终端%s营业报停控越限告警状态\n\n",psAfn0cF06->sGroup[i].bStopCtrlSta ? "处于":"未处于");
                        printf("终端%s当前功率下浮控越限告警状态\n\n",psAfn0cF06->sGroup[i].bDownCtrlSta ? "处于":"未处于");
                        printf("________________________________________________________\n");
                        printf("终端%s月电控越限告警状态\n\n",psAfn0cF06->sGroup[i].bMonthCtrlSta ? "处于":"未处于");
                        printf("终端%s购电控越限告警状态\n\n",psAfn0cF06->sGroup[i].bBuyCtrlSta ? "处于":"未处于");
                    }
                }
            }
            break;

            case CMD_AFN_C_F7_TML_EC_VALUE:
            {
                sMtAfn0cF07 * psAfn0cF07 = (sMtAfn0cF07*)puAppData;
                printf("重要事件计数器EC1: %d\n",psAfn0cF07->ucEc1);
                printf("一般事件计数器EC2: %d\n",psAfn0cF07->ucEc2);
            }
            break;

            case CMD_AFN_C_F8_TML_EVNT_FLAG:
            {
                sMtAfn0cF08 *psAfn0cF08 = (sMtAfn0cF08 *)puAppData;
                INT32 i;
                char *pStr;

                for ( i = 0;i < MT_AFN0CF08_ERC_MAX; i++)
                {
                    if(psAfn0cF08->bErc[i])
                    {
                        switch(i+1)
                        {
                            case MT_ERC_1_INIT:
                                pStr = "ERC1：数据初始化和版本变更记录";
                                break;

                            case MT_ERC_2_PARA_LOSS:
                                pStr = "ERC2：参数丢失记录";
                                break;


                            case MT_ERC_3_PARA_MODIFY:
                                pStr = "ERC3：参数变更记录";
                                break;

                            case MT_ERC_4_STATE_CHANGE:
                                pStr = "ERC4：状态量变位记录";
                                break;

                            case MT_ERC_5_REMOTE_SWITCH:
                                pStr = "ERC5：遥控跳闸记录";
                                break;

                            case MT_ERC_6_PCTRL_SWITCH:
                                pStr = "ERC6：功控跳闸记录";
                                break;
                                
                            case MT_ERC_7_ECTRL_SWITCH:
                                pStr = "ERC7：电控跳闸记录";
                                break;

                            case MT_ERC_8_METER_CHANGE:
                                pStr = "ERC8：电能表参数变更";
                                break;                    

                            case MT_ERC_9_ELEC_EXCP:
                                pStr = "ERC9：电流回路异常";
                                break;

                            case MT_ERC_10_VOLT_EXCP:
                                pStr = "ERC10：电压回路异常";
                                break;

                            case MT_ERC_11_PHASE_EXCP:
                                pStr = "ERC11：相序异常";
                                break;

                            case MT_ERC_12_METER_TIME:
                                pStr = "ERC12：电能表时间超差";
                                break;

                            case MT_ERC_13_METER_FAULT:
                                pStr = "ERC13：电表故障信息";
                                break;

                            case MT_ERC_14_TML_ON_OFF:
                                pStr = "ERC14：终端停/上电事件";
                                break;

                            case MT_ERC_15_HARM_OVER:
                                pStr = "ERC15：谐波越限告警";
                                break;

                            case MT_ERC_16_DC_OVER:
                                pStr = "ERC16：直流模拟量越限记录";
                                break;

                            case MT_ERC_17_UNBL_OVER:
                                pStr = "ERC17：电压/电流不平衡度越限记录";
                                break;

                            case MT_ERC_18_CAPA_LOCK:
                                pStr = "ERC18：电容器投切自锁记录";
                                break;

                            case MT_ERC_19_BUY_PARA:
                                pStr = "ERC19：购电参数设置记录";
                                break;

                            case MT_ERC_20_AUTH_ERROR:
                                pStr = "ERC20：消息认证错误记录";
                                break;
                                
                            case MT_ERC_21_TML_FAULT:
                                pStr = "ERC21：终端故障记录";
                                break;

                            case MT_ERC_22_HAVE_OVER:
                                pStr = "ERC22：有功总电能量差动越限事件记录";
                                break;

                            case MT_ERC_23_ECTRL_WARN:
                                pStr = "ERC23：电控告警事件记录";
                                break;

                            case MT_ERC_24_VOLT_OVER:
                                pStr = "ERC24：电压越限记录";
                                break;

                            case MT_ERC_25_ELEC_OVER:
                                pStr = "ERC25：电流越限记录";
                                break;

                            case MT_ERC_26_SP_OVER:
                                pStr = "ERC26：视在功率越限记录";
                                break;
                                
                            case MT_ERC_27_POWER_DOWN:
                                pStr = "ERC27：电能表示度下降记录";
                                break;

                            case MT_ERC_28_POWER_OVER:
                                pStr = "ERC28：电能量超差记录";
                                break;

                            case MT_ERC_29_METER_FLY:
                                pStr = "ERC29：电能表飞走记录";
                                break;

                            case MT_ERC_30_METER_STOP:
                                pStr = "ERC30：电能表停走记录";
                                break;

                            case MT_ERC_31_READ_FAULT:
                                pStr = "ERC31：终端485抄表失败事件记录";
                                break;
                                
                            case MT_ERC_32_FLOW_OVER:
                                pStr = "ERC32：终端与主站通信流量超门限事件记录";
                                break;      


                            case MT_ERC_33_METER_WORD:
                                pStr = "ERC33：电能表运行状态字变位事件记录";
                                break;

                            case MT_ERC_34_CT_EXCP:
                                pStr = "ERC34：CT异常事件记录";
                                break;
                                
                            case MT_ERC_35_UNKOWN:
                                pStr = "ERC35：发现未知电表事件记录";
                                break;      

                        default:
                            pStr = "错误的事件记录类型";
                            break;

                        }
                        printf("%s: 有事件\n",pStr);
                    }
                }
                
            }
            break;
            
            case CMD_AFN_C_F17_TOTAL_POWER_HAVE:
            {
                sMtTotalPowerHave * psU = (sMtTotalPowerHave*)puAppData;
                printf("当前总加有功功率 %f\n",psU->fsXXX);             
                printf("该命令被暂时当成的温度\n");  
            }
            break;

            case CMD_AFN_C_F18_TOTAL_POWER_NONE:
            {
                sMtTotalPowerNone * psU = (sMtTotalPowerNone*)puAppData;
                printf("当前总加无功功率 %f\n",psU->fsXXX);             
                printf("该命令被暂时当成的湿度\n");  
            }
            break;

            
            case CMD_AFN_C_F31_POWER_CUR:
            {
                sMtAfn0cf31 * psAfn0cF31 = (sMtAfn0cf31*)puAppData;
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psAfn0cF31->sTime.ucYY
                                                         ,psAfn0cF31->sTime.ucMM
                                                         ,psAfn0cF31->sTime.ucDD
                                                         ,psAfn0cF31->sTime.ucHH
                                                         ,psAfn0cF31->sTime.ucmm);

                printf("A相:\n\n");
                printf("正向有功电能示值: %.4f\n",psAfn0cF31->sPhaseA.dFrthHavePower);
                printf("反向有功电能示值: %.4f\n",psAfn0cF31->sPhaseA.dBackHavePower);
                printf("组合无功1电能示值: %.2f\n",psAfn0cF31->sPhaseA.fComNonePower1);
                printf("组合无功2电能示值: %.2f\n",psAfn0cF31->sPhaseA.fComNonePower2);

                printf("B相:\n\n");
                printf("正向有功电能示值: %.4f\n",psAfn0cF31->sPhaseB.dFrthHavePower);
                printf("反向有功电能示值: %.4f\n",psAfn0cF31->sPhaseB.dBackHavePower);
                printf("组合无功1电能示值: %.2f\n",psAfn0cF31->sPhaseB.fComNonePower1);
                printf("组合无功2电能示值: %.2f\n",psAfn0cF31->sPhaseB.fComNonePower2);


                printf("C相:\n\n");
                printf("正向有功电能示值: %.4f\n",psAfn0cF31->sPhaseC.dFrthHavePower);
                printf("反向有功电能示值: %.4f\n",psAfn0cF31->sPhaseC.dBackHavePower);
                printf("组合无功1电能示值: %.2f\n",psAfn0cF31->sPhaseC.fComNonePower1);
                printf("组合无功2电能示值: %.2f\n",psAfn0cF31->sPhaseC.fComNonePower2);  
            }
            break;

            case CMD_AFN_C_F57_CURT_HARM_VALUE:
            {
                sMtAfn0cF57 * psAfn0cF57 = (sMtAfn0cF57*)puAppData;
                UINT32  i;
                printf("谐波次数:  %d\n",psAfn0cF57->ucN);
                                                         
                printf("A相谐波电压:\n\n");
                for ( i = 0; i < psAfn0cF57->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF57->sUa.bfXXX_X[i] )
                    {
                        printf("%d次谐波电压有效值: %.1f\n",i+2,psAfn0cF57->sUa.fXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电压有效值: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");

                printf("\nB相谐波电压:\n\n");
                for ( i = 0; i < psAfn0cF57->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF57->sUb.bfXXX_X[i] )
                    {
                        printf("%d次谐波电压有效值: %.2f\n",i+2,psAfn0cF57->sUb.fXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电压有效值: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");
                printf("\nC相谐波电压:\n\n");
                for ( i = 0; i < psAfn0cF57->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF57->sUc.bfXXX_X[i] )
                    {
                        printf("%d次谐波电压有效值: %.2f\n",i+2,psAfn0cF57->sUc.fXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电压有效值: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");
                printf("\nA相谐波电流:\n\n");
                for ( i = 0; i < psAfn0cF57->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF57->sIa.bfsXX_XX[i] )
                    {
                        printf("%d次谐波电流有效值: %.2f\n",i+2,psAfn0cF57->sIa.fsXX_XX[i]);
                    }else
                    {
                        printf("%d次谐波电流: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");
                printf("\nB相谐波电流:\n\n");
                for ( i = 0; i < psAfn0cF57->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF57->sIb.bfsXX_XX[i] )
                    {
                        printf("%d次谐波电流有效值: %.2f\n",i+2,psAfn0cF57->sIb.fsXX_XX[i]);
                    }else
                    {
                        printf("%d次谐波电流: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");
                printf("\nC相谐波电流:\n\n");
                for ( i = 0; i < psAfn0cF57->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF57->sIc.bfsXX_XX[i] )
                    {
                        printf("%d次谐波电流有效值: %.2f\n",i+2,psAfn0cF57->sIc.fsXX_XX[i]);
                    }else
                    {
                        printf("%d次谐波电流: 无\n",i+2);
                    }
                }  
            }
            break;
            
            case CMD_AFN_C_F58_CURT_HARM_RATE:
            {
                sMtAfn0cF58 * psAfn0cF58 = (sMtAfn0cF58*)puAppData;
                UINT32  i;
                printf("谐波次数:  %d\n",psAfn0cF58->ucN);
                                                         
                printf("A相谐波电压:\n\n");
                if( TRUE == psAfn0cF58->sUa.sTotal.bfsXXX_X )
                {
                    printf("总谐波电压含有率: %.1f\n",psAfn0cF58->sUa.sTotal.fsXXX_X);
                }else
                {
                    printf("总谐波电压含有率: 无\n");
                }
                for ( i = 0; i < psAfn0cF58->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF58->sUa.bfsXXX_X[i] )
                    {
                        printf("%d次谐波电压含有率: %.1f\n",i+2,psAfn0cF58->sUa.fsXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电压含有率: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");

                printf("\nB相谐波电压:\n\n");
                if( TRUE == psAfn0cF58->sUb.sTotal.bfsXXX_X )
                {
                    printf("总谐波电压含有率: %.1f\n",psAfn0cF58->sUb.sTotal.fsXXX_X);
                }else
                {
                    printf("总谐波电压含有率: 无\n");
                }
                for ( i = 0; i < psAfn0cF58->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF58->sUb.bfsXXX_X[i] )
                    {
                        printf("%d次谐波电压含有率: %.2f\n",i+2,psAfn0cF58->sUb.fsXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电压含有率: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");
                printf("\nC相谐波电压:\n\n");
                if( TRUE == psAfn0cF58->sUc.sTotal.bfsXXX_X )
                {
                    printf("总谐波电压含有率: %.1f\n",psAfn0cF58->sUc.sTotal.fsXXX_X);
                }else
                {
                    printf("总谐波电压含有率: 无\n");
                }                
                for ( i = 0; i < psAfn0cF58->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF58->sUc.bfsXXX_X[i] )
                    {
                        printf("%d次谐波电压含有率: %.2f\n",i+2,psAfn0cF58->sUc.fsXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电压含有率: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");
                printf("\nA相谐波电流:\n\n");
                if( TRUE == psAfn0cF58->sIa.sTotal.bfsXXX_X )
                {
                    printf("总谐波电压含有率: %.1f\n",psAfn0cF58->sIa.sTotal.fsXXX_X);
                }else
                {
                    printf("总谐波电压含有率: 无\n");
                }                
                for ( i = 0; i < psAfn0cF58->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF58->sIa.bfsXXX_X[i] )
                    {
                        printf("%d次谐波电流含有率: %.2f\n",i+2,psAfn0cF58->sIa.fsXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电流含有率: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");
                printf("\nB相谐波电流:\n\n");
                if( TRUE == psAfn0cF58->sIb.sTotal.bfsXXX_X )
                {
                    printf("总谐波电压含有率: %.1f\n",psAfn0cF58->sIb.sTotal.fsXXX_X);
                }else
                {
                    printf("总谐波电压含有率: 无\n");
                }                
                for ( i = 0; i < psAfn0cF58->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF58->sIb.bfsXXX_X[i] )
                    {
                        printf("%d次谐波电流含有率: %.2f\n",i+2,psAfn0cF58->sIb.fsXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电流含有率: 无\n",i+2);
                    }
                }
                printf("*****************************************************\n");
           
                printf("\nC相谐波电流:\n\n");
                if( TRUE == psAfn0cF58->sIc.sTotal.bfsXXX_X )
                {
                    printf("总谐波电压含有率: %.1f\n",psAfn0cF58->sIc.sTotal.fsXXX_X);
                }else
                {
                    printf("总谐波电压含有率: 无\n");
                }     
                for ( i = 0; i < psAfn0cF58->ucN - 1;i++)
                {
                    if( TRUE == psAfn0cF58->sIc.bfsXXX_X[i] )
                    {
                        printf("%d次谐波电流含有率: %.2f\n",i+2,psAfn0cF58->sIc.fsXXX_X[i]);
                    }else
                    {
                        printf("%d次谐波电流含有率: 无\n",i+2);
                    }
                }  
            }
            break;  

             case CMD_AFN_C_F73_DC_RLTM_DATA:
            {
                float *pData = (float*)puAppData;
                printf("Dc = %f\n", *pData);
             }
             break;
            case CMD_AFN_C_F129_FRTH_HAVE_POWR_C:
            {
                sMtAfn0cf129 * psAfn0cF129 = (sMtAfn0cf129*)puAppData;
                UINT8 i;
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psAfn0cF129->sTime.ucYY
                                                         ,psAfn0cF129->sTime.ucMM
                                                         ,psAfn0cF129->sTime.ucDD
                                                         ,psAfn0cF129->sTime.ucHH
                                                         ,psAfn0cF129->sTime.ucmm);

                printf("费率数: %d\n",psAfn0cF129->ucM);
                printf("正向有功总电能示值: %.4f\n",psAfn0cF129->dTotalValue);
                for (i = 0; i < psAfn0cF129->ucM;i++)
                {
                    printf("费率 %d 正向有功总电能示值: %.4f\n",i+1,psAfn0cF129->dValueItem[i]);
                }
            }
            break;

            case CMD_AFN_C_F130_FRTH_NONE_POWR_C:
            {
                sMtAfn0cf130 * psAfn0cF130 = (sMtAfn0cf130*)puAppData;
                UINT8 i;
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psAfn0cF130->sTime.ucYY
                                                         ,psAfn0cF130->sTime.ucMM
                                                         ,psAfn0cF130->sTime.ucDD
                                                         ,psAfn0cF130->sTime.ucHH
                                                         ,psAfn0cF130->sTime.ucmm);

                printf("费率数: %d\n",psAfn0cF130->ucM);
                printf("正向无功总电能示值: %.2f\n",psAfn0cF130->dTotalValue);
                for (i = 0; i < psAfn0cF130->ucM;i++)
                {
                    printf("费率 %d 正向无功总电能示值: %.2f\n",i+1,psAfn0cF130->dValueItem[i]);
                }
            }
            break;

            case CMD_AFN_C_F166_METR_MODIFY_RECD:
            {
                sMtAfn0cf166 * psAfn0cF166 = (sMtAfn0cf166*)puAppData;
               
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psAfn0cF166->sTime.ucYY
                                                         ,psAfn0cF166->sTime.ucMM
                                                         ,psAfn0cF166->sTime.ucDD
                                                         ,psAfn0cF166->sTime.ucHH
                                                         ,psAfn0cF166->sTime.ucmm);

               printf("电能表时钟修改次数 %d\n",psAfn0cF166->sOne.usTimes);
               printf("电能表最近一次时钟修改时间 %d年%d月%d日 %d时%d分\n",psAfn0cF166->sOne.sClock.ucYY
                                                                          ,psAfn0cF166->sOne.sClock.ucMM
                                                                          ,psAfn0cF166->sOne.sClock.ucDD
                                                                          ,psAfn0cF166->sOne.sClock.ucHH
                                                                          ,psAfn0cF166->sOne.sClock.ucmm);

               printf("电能表时段参数修改次数 %d\n",psAfn0cF166->sOther.usTimes);
               printf("电能表最近一次时段参数修改时间 %d年%d月%d日 %d时%d分\n",psAfn0cF166->sOther.sClock.ucYY
                                                                              ,psAfn0cF166->sOther.sClock.ucMM
                                                                              ,psAfn0cF166->sOther.sClock.ucDD
                                                                              ,psAfn0cF166->sOther.sClock.ucHH
                                                                              ,psAfn0cF166->sOther.sClock.ucmm);
            }
            break;

            case CMD_AFN_C_F167_METR_BUY_USE:
            {
                sMtAfn0cf167 * psAfn0cF167 = (sMtAfn0cf167*)puAppData;
     
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psAfn0cF167->sTime.ucYY
                                                         ,psAfn0cF167->sTime.ucMM
                                                         ,psAfn0cF167->sTime.ucDD
                                                         ,psAfn0cF167->sTime.ucHH
                                                         ,psAfn0cF167->sTime.ucmm);

               printf("购电次数 %d\n",psAfn0cF167->usBuyTimes);
               printf("剩余金额 %.04f\n",psAfn0cF167->dCashLeft);
               printf("累计购电金额 %.04f\n",psAfn0cF167->dCashTotal);
               printf("剩余电量 %.02f\n",psAfn0cF167->dElecLeft);
               printf("透支电量 %.02f\n",psAfn0cF167->dElecOut);
               printf("累计购电量 %.02f\n",psAfn0cF167->dElecTotal);
               printf("赊欠门限电量 %.02f\n",psAfn0cF167->dElecLimit);
               printf("报警电量 %.02f\n",psAfn0cF167->dElecWarn);
               printf("故障电量 %.02f\n",psAfn0cF167->dElecFault);
             }
            break; 

            case CMD_AFN_C_F601_RUN_STATE:
            {
                sMtAfn0cf601* pData = (sMtAfn0cf601*)puAppData;

                switch (pData->rFS)
                {
                case FS_UNKOWN:
                    pStr = "未知";
                    break;
                case FS_GO:
                    pStr = "正在执行";
                    break;
                case FS_DONE:
                    pStr = "完成";
                    break;
                default:
                    pStr = "错误";
                    break;
                }
                printf("读取下装终端档案完成状态：%s\n", pStr);
                switch (pData->smRS)
                {
                case SM_RS_FF:
                    pStr = "台区管理单元";
                    break;
                case SM_RS_UD:
                    pStr = "高供低计";
                    break;
                case SM_RS_UU:
                    pStr = "高供高计";
                    break;
                default:
                    pStr = " 未知";
                    break;
                }
                printf("台区管家\n%s\n", pStr);
                switch (pData->smWS)
                {
                case SM_WS_UNKOWN:
                    pStr = "未知";
                    break;
                case SM_WS_DONE:
                    pStr = "抄读完成总表";
                    break;
                case SM_WS_FC:
                    pStr = "只能抄读完成高采";
                    break;
                case SM_WS_GO:
                    pStr = "正常工作";
                    break;
                default:
                    pStr = " 错误";
                    break;
                }
                printf("台区管家工作状态：%s\n", pStr);
                switch (pData->uCT)
                {
                case UCT_UNKOWN:
                    pStr = "未知";
                    break;
                case UCT_GPRS:
                    pStr = "GPRS";
                    break;
                case UCT_ENET:
                    pStr = "以太网";
                    break;
                default:
                    pStr = " 错误";
                    break;
                }
                printf("当前使用上行信道类型：%s\n", pStr);
                switch (pData->dCT)
                {
                case DCT_UNKOWN:
                    pStr = "未知";
                    break;
                case DCT_RS485:
                    pStr = "RS485";
                    break;
                case DCT_RS232:
                    pStr = "RS232";
                    break;
                case DCT_USB:
                    pStr = "USB(红外)";
                    break;
                default:
                    pStr = " 错误";
                    break;
                }
                printf("当前使用下行信道类型：%s\n", pStr);
                printf("当前下行信道个数：%d\n", pData->usN);
                for (i = 0; i < pData->usN; i++) {
                    switch (pData->cInf[i].CT) {
                    case CT_UNKOWN:
                        pStr = "未知";
                        break;
                    case CT_RS485:
                        pStr = "RS485";
                        break;
                    case CT_RS232:
                        pStr = "RS232";
                        break;
                    case CT_USB:
                        pStr = "USB(红外)";
                        break;
                    case CT_LORA:
                        pStr = "LORA";
                        break;
                    default:
                        pStr = " 错误";
                        break;
                    }
                    printf("第%d个信道类型：%s\n", i + 1, pStr);
                    switch (pData->cInf[i].CS) {
                    case CS_UNKOWN:
                        pStr = "未尝试";
                        break;
                    case CS_SUCESS:
                        pStr = "成功";
                        break;
                    case CS_FAIL:
                        pStr = "失败";
                        break;
                    default:
                        pStr = " 错误";
                        break;
                    }
                    printf("第%d个信道状态：%s\n", i + 1, pStr);
                }
            }
            break;

            case CMD_AFN_C_F602_METER_PROP:
            {
                sMtAfn0cf602* psU = (sMtAfn0cf602*)puAppData;

                switch (psU->usCRAPN.eBaudRate)
                {
                case MT_BAUD_DEFAULT:
                    pStr = "无需设置或使用默认";
                    break;
                case MT_BAUD_600:
                    pStr = "600";
                    break;
                case MT_BAUD_1200:
                    pStr = "1200";
                    break;
                case MT_BAUD_2400:
                    pStr = "2400";
                    break;
                case MT_BAUD_4800:
                    pStr = "4800";
                    break;
                case MT_BAUD_7200:
                    pStr = "7200";
                    break;
                case MT_BAUD_9600:
                    pStr = "9600";
                    break;
                case MT_BAUD_19200:
                    pStr = "19200";
                    break;
                default:
                    pStr = "未知";
                    break;
                }
                printf("通信速率:波特率 %s\n", pStr);

                printf("端口号:%02X\n", psU->usCRAPN.ucPort);

                switch (psU->usCPY)
                {
                case MY_PROTO_DEFAULT:
                    pStr = "终端无需对本序号的电能表/交流采样装置进行抄表";
                    break;
                case MY_PROTO_DLT645_97:
                    pStr = "DL/T 645-1997";
                    break;
                case MY_PROTO_AC:
                    pStr = "交流采样装置通信协议";
                    break;
                case MY_PROTO_OOP:
                    pStr = "oop协议";
                    break;
                case MY_PROTO_DLT645_07:
                    pStr = "DL/T 645-2007";
                    break;
                case MY_PROTO_SERIAL:
                    pStr = "“串行接口连接窄带低压载波通信模块”接口协议";
                    break;
                default:
                    pStr = "备用";
                    break;
                }
                printf("通信协议类型:%s\n", pStr);

                int i = 0;
                UINT64 address = 0;
                for (i = 0; i < 12; i++) {
                    address += (psU->usMA[11 - i] & 0x0F) << (i * 4);
                }
                printf("通信地址:%X\n", address);
            }
            break;

            case CMD_AFN_C_F604_EM_ABNORMAL_ANAL:
            {
                sMtAfn0cf604* pData = (sMtAfn0cf604*)puAppData;
                printf("总执行轮次：%d\n", pData->eAllTurn);
                printf("上一次结束时间：%02d年%02d月%02d日 %02d:%02d:%02d\n", 
                        pData->sTime.ucYear,
                        pData->sTime.ucMonth,
                        pData->sTime.ucDay, 
                        pData->sTime.ucHour,
                        pData->sTime.ucMinute,
                        pData->sTime.ucSecond);
                for (i = 0; i < 256; i++) {
                    for (j = 0; j < 8; j++) {
                        if (pData->eEMAblAnalySuc[i].bEMAblAnalySuc[j] == TRUE) printf("本轮分析结束电表测量点：%d\n", i * 8 + j + 1);
                    }
                }
                for (i = 0; i < 256; i++) {
                    for (j = 0; j < 8; j++) {
                        if (pData->eTwoDaysFrozen[i].bTwoDaysFrozen[j] == TRUE) printf("存在2日日冻结电能表测量点：%d\n", i * 8 + j + 1);
                    }
                }
                /*
                for( i = 0; i < 256; i++){
                    for(  j = 0; j < 8; j++){
                        if(pData->eEMAblAnalyFailed[i].bEMAblAnalyFailed[j]  == TRUE) printf("电能表异常情况分析失败电能表测量点：%d\n", i  * 8 + j + 1);
                    }
                }
                */
            }
            break;

            case CMD_AFN_C_F625_TOTAL_METER_ABN:
            {
                sMtTotalMeterAbn* pData = (sMtTotalMeterAbn*)puAppData;
                int k = 0;
                printf("测量点总个数:%d\n", pData->usN);
                printf("本帧测量点个数:%d\n", pData->nowN);
                for (i = 0; i < pData->nowN; i++)
                {
                    printf("第%d个电能表测量点:%d\n", i + 1, pData->sOne[i].meterPoint);
                    printf("第%d个电能表通信地址:", i + 1);
                    for (k = 5; k >= 0; k--)
                    {
                        printf("%02x", pData->sOne[i].meterAdderss[k]);
                    }
                    printf("\n");
                    printf("发生异常类型个数:%d\n", pData->sOne[i].abnN);
                    for (j = 0; j < pData->sOne[i].abnN; j++)
                    {
                        switch (pData->sOne[i].sTwo[j].abnType)
                        {
                        case 0x01:
                            pStr = "开表盖";
                            break;
                        case 0x02:
                            pStr = "零火线电流";
                            break;
                        case 0x03:
                            pStr = "反向潮流";
                            break;
                        case 0x04:
                            pStr = "三相表电压逆相序/单相表电压LN互逆";
                            break;
                        case 0x05:
                            pStr = "时钟超差";
                            break;
                        case 0x06:
                            pStr = "时钟电池欠压";
                            break;
                        case 0x07:
                            pStr = "失压";
                            break;
                        case 0x08:
                            pStr = "失流";
                            break;
                        case 0x09:
                            pStr = "断相";
                            break;
                        case 0x10:
                            pStr = "三相表电流逆相序";
                        case 0x11:
                            pStr = "电压串线";
                            break;
                        case 0x12:
                            pStr = "电流串线";
                            break;
                        case 0x13:
                            pStr = "电能表连续电量无变化";
                            break;
                        case 0x14:
                            pStr = "电能表停走";
                            break;
                        case 0x15:
                            pStr = "电能表飞走";
                            break;
                        case 0x16:
                            pStr = "电能表倒走";
                            break;
                        case 0x17:
                            pStr = "电能表电量不平";
                            break;
                        case 0x18:
                            pStr = "火零线漏电异常";
                            break;
                        case 0x19:
                            pStr = "零线电流不采样或未接线";
                            break;
                        case 0x20:
                            pStr = "光伏表过压告警，反向电量超过一定门限，电压过限";
                            break;
                        case 0x21:
                            pStr = "单相表疑似共零";
                            break;
                        default:
                            pStr = "备用";
                            break;
                        }
                        printf("第%d个电能表异常情况类型%d:%s\n", i + 1, j + 1, pStr);
                        printf("发生时标:%d年%d月%d日\n", pData->sOne[i].sTwo[j].sTd_d.ucYY
                            , pData->sOne[i].sTwo[j].sTd_d.ucMM
                            , pData->sOne[i].sTwo[j].sTd_d.ucDD);
                    }
                        // printf("发生时标:%d年%d月%d日\n", pData->sOne[7].sTwo[1].sTd_d.ucYY
                        //     , pData->sOne[7].sTwo[1].sTd_d.ucMM
                        //     , pData->sOne[7].sTwo[1].sTd_d.ucDD);
                    printf("\n");
                }
            }
            break;


            case CMD_AFN_C_F627_CON_FROZEN_STATE:
            {
                sMtConFrozenState* pData = (sMtConFrozenState*)puAppData;
                for (i = 0; i < 256; i++) {
                    for (j = 0; j < 8; j++) {
                        if (pData->eFrozenSta[i].bFrozenSta[j] == TRUE) printf("%d:有效\n", i * 8 + j);
                    }
                }
            }
            break;

            case CMD_AFN_C_F628_PT_FROZEN_STATE:
            {
                sMtPTFrozenState* pData = (sMtPTFrozenState*)puAppData;
                for (i = 0; i < 256; i++) {
                    for (j = 0; j < 8; j++) {
                        if (pData->eFrozenSta[i].bFrozenSta[j] == TRUE) printf("%d:有效\n", i * 8 + j);
                    }
                }
            }
            break;

            case CMD_AFN_C_F629_RESULT_STATISTICS:
            {
                sMtAfn0cF629* pData = (sMtAfn0cF629*)puAppData;
                printf("集中器有效档案数量：%d\n", pData->ucValidFileNum);
                printf("集中器有日冻结数量：%d\n", pData->ucPerFrozenNum);
                printf("台区管家能透传到冻结电能表数量：%d\n", pData->uPtWhNum);
            }
            break;

            case CMD_AFN_C_F633_METER_RUNNING_DATA:
            {
                sMtAfn0cf633* pData = (sMtAfn0cf633*)puAppData;
                (pData->readTime.ucMonth>12||pData->readTime.ucDay>31||pData->readTime.ucHour>23||pData->readTime.ucMinute>59||pData->readTime.ucSecond>59)?printf("抄表时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n", pData->readTime.ucYear, pData->readTime.ucMonth, pData->readTime.ucDay, pData->readTime.ucHour, pData->readTime.ucMinute, pData->readTime.ucSecond);
                printf("运行状态字1：%d\n", pData->stateData1);
                printf("运行状态字2：%d\n", pData->stateData2);
                printf("运行状态字3：%d\n", pData->stateData3);
                printf("运行状态字4（A相）：%d\n", pData->stateData4);
                printf("运行状态字5（B相）：%d\n", pData->stateData5);
                printf("运行状态字6（C相）：%d\n", pData->stateData6);
                printf("运行状态字7（合相）：%d\n", pData->stateData7);
            }
            break;

            case CMD_AFN_C_F634_ZL_ELEC_OUTLIERS:
            {
                sMtAfn0cf634* pData = (sMtAfn0cf634*)puAppData;
                printf("个数：%d\n", pData->usN);
                for (i = 0; i < pData->usN; i++)
                {
                    printf("第%d次零线电流：%.3f\n",i+1, pData->s[i].zElec);
                    printf("第%d次火线电流：%.3f\n",i+1, pData->s[i].lElec);
                    printf("第%d次抄读时间：%d年%d月%d星期%d日%d时%d分%d秒\n",i+1, pData->s[i].readTime.ucYear
                                                                                 , pData->s[i].readTime.ucMonth
                                                                                 , pData->s[i].readTime.ucWeek
                                                                                 , pData->s[i].readTime.ucDay
                                                                                 , pData->s[i].readTime.ucHour
                                                                                 , pData->s[i].readTime.ucMinute
                                                                                 , pData->s[i].readTime.ucSecond);
                }
            }
            break;

            case CMD_AFN_C_F635_UNCOVER_OUTLIERS:
            {
                sMtAfn0cF635* pData = (sMtAfn0cF635*)puAppData;
                printf("开表盖总次数：");
                for (i = 0; i < 3; i++)
                {
                    printf("%02x", pData->eSumUncoverTime[i]);
                }
                printf("\n");
                printf("本轮次发生开表盖次数：%d\n", pData->eNowUncoverTime);
                for (i = 0; i < pData->eNowUncoverTime; i++)
                {
                    printf("上%d次开盖事件开始时间：%d年%d月%d星期%d日%d时%d分%d秒\n" ,i+1, pData->eUncoverEventTime[i].UncoverEventStartTime.ucYear
                                                                            , pData->eUncoverEventTime[i].UncoverEventStartTime.ucMonth
                                                                            , pData->eUncoverEventTime[i].UncoverEventStartTime.ucWeek
                                                                            , pData->eUncoverEventTime[i].UncoverEventStartTime.ucDay
                                                                            , pData->eUncoverEventTime[i].UncoverEventStartTime.ucHour
                                                                            , pData->eUncoverEventTime[i].UncoverEventStartTime.ucMinute
                                                                            , pData->eUncoverEventTime[i].UncoverEventStartTime.ucSecond);
                    printf("上%d次开盖事件结束时间：%d年%d月%d星期%d日%d时%d分%d秒\n" ,i+1, pData->eUncoverEventTime[i].UncoverEventEndTime.ucYear
                                                                            , pData->eUncoverEventTime[i].UncoverEventEndTime.ucMonth
                                                                            , pData->eUncoverEventTime[i].UncoverEventEndTime.ucWeek
                                                                            , pData->eUncoverEventTime[i].UncoverEventEndTime.ucDay
                                                                            , pData->eUncoverEventTime[i].UncoverEventEndTime.ucHour
                                                                            , pData->eUncoverEventTime[i].UncoverEventEndTime.ucMinute
                                                                            , pData->eUncoverEventTime[i].UncoverEventEndTime.ucSecond);
                }

            }
            break;

            case CMD_AFN_C_F639_CLOCK_ERR_DATA:
            {
                sMtAfn0cf639* pData = (sMtAfn0cf639*)puAppData;
                (pData->readTime.ucMonth>12||pData->readTime.ucDay>31||pData->readTime.ucHour>23||pData->readTime.ucMinute>59||pData->readTime.ucSecond>59)?printf("抄读成功时间: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄读成功时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n", pData->readTime.ucYear, pData->readTime.ucMonth, pData->readTime.ucDay, pData->readTime.ucHour, pData->readTime.ucMinute, pData->readTime.ucSecond);
                (pData->meterClock.ucMonth>12||pData->meterClock.ucDay>31||pData->meterClock.ucHour>23||pData->meterClock.ucMinute>59||pData->meterClock.ucSecond>59)?printf("电能表时钟: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("电能表时钟：%02d年%02d月%02d日%02d时%02d分%02d秒\n", pData->meterClock.ucYear, pData->meterClock.ucMonth, pData->meterClock.ucDay, pData->meterClock.ucHour, pData->meterClock.ucMinute, pData->meterClock.ucSecond);
                printf("通信时长：%d s\n", pData->ElecTime);
                printf("电能表时钟误差值：");
                if (pData->ErrValue & 0x80000000)
                {
                    printf("-");
                }
                else
                {
                    printf("+");
                }
                printf("%d s\n", (pData->ErrValue & 0x7FFFFFFF));
            }
            break;

            case CMD_AFN_C_F640_METER_OUTAGE_DATA:
            {
                sMtAfn0cf640* pData = (sMtAfn0cf640*)puAppData;
                (pData->readTime.ucMonth>12||pData->readTime.ucDay>31||pData->readTime.ucHour>23||pData->readTime.ucMinute>59||pData->readTime.ucSecond>59)?printf("抄表时间: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n", pData->readTime.ucYear, pData->readTime.ucMonth, pData->readTime.ucDay, pData->readTime.ucHour, pData->readTime.ucMinute, pData->readTime.ucSecond);
                (pData->lastOutageTime.ucMonth>12||pData->lastOutageTime.ucDay>31||pData->lastOutageTime.ucHour>23||pData->lastOutageTime.ucMinute>59||pData->lastOutageTime.ucSecond>59)?printf("电能表上一次停电时间: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("电能表上一次停电时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n", pData->lastOutageTime.ucYear, pData->lastOutageTime.ucMonth, pData->lastOutageTime.ucDay, pData->lastOutageTime.ucHour, pData->lastOutageTime.ucMinute, pData->lastOutageTime.ucSecond);
                (pData->lastPowerTime.ucMonth>12||pData->lastPowerTime.ucDay>31||pData->lastPowerTime.ucHour>23||pData->lastPowerTime.ucMinute>59||pData->lastPowerTime.ucSecond>59)?printf("电能表上一次上电时间: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("电能表上一次上电时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n", pData->lastPowerTime.ucYear, pData->lastPowerTime.ucMonth, pData->lastPowerTime.ucDay, pData->lastPowerTime.ucHour, pData->lastPowerTime.ucMinute, pData->lastPowerTime.ucSecond);
            }
            break;

            case CMD_AFN_C_F641_EM_OCR:{
                sMtOpenCoverRecord* pData = (sMtOpenCoverRecord*)puAppData;
                (pData->usMRT.ucMonth>12||pData->usMRT.ucDay>31||pData->usMRT.ucHour>23||pData->usMRT.ucMinute>59||pData->usMRT.ucSecond>59)?printf("抄表时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usMRT.ucYear,
                                                               pData->usMRT.ucMonth,
                                                               pData->usMRT.ucDay,
                                                               pData->usMRT.ucHour,
                                                               pData->usMRT.ucMinute,
                                                               pData->usMRT.ucSecond);
                (pData->usOT.ucMonth>12||pData->usOT.ucDay>31||pData->usOT.ucHour>23||pData->usOT.ucMinute>59||pData->usOT.ucSecond>59)?printf("发生时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("发生时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usOT.ucYear,
                                                               pData->usOT.ucMonth,
                                                               pData->usOT.ucDay,
                                                               pData->usOT.ucHour,
                                                               pData->usOT.ucMinute,
                                                               pData->usOT.ucSecond);
                (pData->usET.ucMonth>12||pData->usET.ucDay>31||pData->usET.ucHour>23||pData->usET.ucMinute>59||pData->usET.ucSecond>59)?printf("结束时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("结束时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usET.ucYear,
                                                               pData->usET.ucMonth,
                                                               pData->usET.ucDay,
                                                               pData->usET.ucHour,
                                                               pData->usET.ucMinute,
                                                               pData->usET.ucSecond);
                printf("\n开表盖前：\n");
                pData->usTPPBOTMC>1000000.00?printf("\t正向有功总电能: 数值超出范围 kWh\n"):
                printf("\t正向有功总电能: %9.2f kWh\n",pData->usTPPBOTMC);
                pData->usTRAPBOTMC>1000000.00?printf("\t反向有功总电能: 数值超出范围 kWh\n"):
                printf("\t反向有功总电能: %9.2f kWh\n",pData->usTRAPBOTMC);
                pData->usTRPITFIQBOTMC>1000000.00?printf("\t第一象限无功总电能: 数值超出范围 kvarh\n"):
                printf("\t第一象限无功总电能: %9.2f kvarh\n",pData->usTRPITFIQBOTMC);
                pData->usTRPITSEQBOTMC>1000000.00?printf("\t第二象限无功总电能: 数值超出范围 kvarh\n"):
                printf("\t第二象限无功总电能: %9.2f kvarh\n",pData->usTRPITSEQBOTMC);
                pData->usTRPITTHQBOTMC>1000000.00?printf("\t第三象限无功总电能: 数值超出范围 kvarh\n"):
                printf("\t第三象限无功总电能: %9.2f kvarh\n",pData->usTRPITTHQBOTMC);
                pData->usTRPITFOQBOTMC>1000000.00?printf("\t第四象限无功总电能: 数值超出范围 kvarh\n"):
                printf("\t第四象限无功总电能: %9.2f kvarh\n",pData->usTRPITFOQBOTMC);
                printf("\n开表盖后:\n");
                pData->usTPPAOTMC>1000000.00?printf("\t正向有功总电能: 数值超出范围 kWh\n"):
                printf("\t正向有功总电能: %9.2f kWh\n",pData->usTPPAOTMC);
                pData->usTRAPAOTMC>1000000.00?printf("\t反向有功总电能: 数值超出范围 kWh\n"):
                printf("\t反向有功总电能: %9.2f kWh\n",pData->usTRAPAOTMC);
                pData->usTRPITFIQAOTMC>1000000.00?printf("\t第一象限无功总电能: 数值超出范围 kvarh\n"):
                printf("\t第一象限无功总电能: %9.2f kvarh\n",pData->usTRPITFIQAOTMC);
                pData->usTRPITSEQAOTMC>1000000.00?printf("\t第二象限无功总电能: 数值超出范围 kvarh\n"):
                printf("\t第二象限无功总电能: %9.2f kvarh\n",pData->usTRPITSEQAOTMC);
                pData->usTRPITTHQAOTMC>1000000?printf("\t第三象限无功总电能: 数值超出范围 kvarh\n"):
                printf("\t第三象限无功总电能: %9.2f kvarh\n",pData->usTRPITTHQAOTMC);
                pData->usTRPITFOQAOTMC>1000000.00?printf("\t第四象限无功总电能: 数值超出范围 kvarh\n"):
                printf("\t第四象限无功总电能: %9.2f kvarh\n",pData->usTRPITFOQAOTMC);

            }
            break;

            case CMD_AFN_C_F642_EM_LOPR:
            {
                sMtLossPressureRecord* pData = (sMtLossPressureRecord*)puAppData;
                (pData->usMRT.ucMonth>12||pData->usMRT.ucDay>31||pData->usMRT.ucHour>23||pData->usMRT.ucMinute>59||pData->usMRT.ucSecond>59)?printf("抄表时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usMRT.ucYear,
                                                               pData->usMRT.ucMonth,
                                                               pData->usMRT.ucDay,
                                                               pData->usMRT.ucHour,
                                                               pData->usMRT.ucMinute,
                                                               pData->usMRT.ucSecond);
                (pData->usOT.ucMonth>12||pData->usOT.ucDay>31||pData->usOT.ucHour>23||pData->usOT.ucMinute>59||pData->usOT.ucSecond>59)?printf("发生时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("发生时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usOT.ucYear,
                                                               pData->usOT.ucMonth,
                                                               pData->usOT.ucDay,
                                                               pData->usOT.ucHour,
                                                               pData->usOT.ucMinute,
                                                               pData->usOT.ucSecond);
                (pData->usET.ucMonth>12||pData->usET.ucDay>31||pData->usET.ucHour>23||pData->usET.ucMinute>59||pData->usET.ucSecond>59)?printf("结束时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("结束时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usET.ucYear,
                                                               pData->usET.ucMonth,
                                                               pData->usET.ucDay,
                                                               pData->usET.ucHour,
                                                               pData->usET.ucMinute,
                                                               pData->usET.ucSecond);


            }
            break;

            case CMD_AFN_C_F643_EM_LOFR:
            {
                sMtLossFlowRecord* pData = (sMtLossFlowRecord*)puAppData;
                (pData->usMRT.ucMonth>12||pData->usMRT.ucDay>31||pData->usMRT.ucHour>23||pData->usMRT.ucMinute>59||pData->usMRT.ucSecond>59)?printf("抄表时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usMRT.ucYear,
                                                               pData->usMRT.ucMonth,
                                                               pData->usMRT.ucDay,
                                                               pData->usMRT.ucHour,
                                                               pData->usMRT.ucMinute,
                                                               pData->usMRT.ucSecond);
                (pData->usOT.ucMonth>12||pData->usOT.ucDay>31||pData->usOT.ucHour>23||pData->usOT.ucMinute>59||pData->usOT.ucSecond>59)?printf("发生时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("发生时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usOT.ucYear,
                                                               pData->usOT.ucMonth,
                                                               pData->usOT.ucDay,
                                                               pData->usOT.ucHour,
                                                               pData->usOT.ucMinute,
                                                               pData->usOT.ucSecond);
                (pData->usET.ucMonth>12||pData->usET.ucDay>31||pData->usET.ucHour>23||pData->usET.ucMinute>59||pData->usET.ucSecond>59)?printf("结束时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("结束时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usET.ucYear,
                                                               pData->usET.ucMonth,
                                                               pData->usET.ucDay,
                                                               pData->usET.ucHour,
                                                               pData->usET.ucMinute,
                                                               pData->usET.ucSecond);


            }
            break;

            case CMD_AFN_C_F644_EM_PBR:
            {
                sMtPhaseBreakRecord* pData = (sMtPhaseBreakRecord*)puAppData;
                (pData->usMRT.ucMonth>12||pData->usMRT.ucDay>31||pData->usMRT.ucHour>23||pData->usMRT.ucMinute>59||pData->usMRT.ucSecond>59)?printf("抄表时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usMRT.ucYear,
                                                               pData->usMRT.ucMonth,
                                                               pData->usMRT.ucDay,
                                                               pData->usMRT.ucHour,
                                                               pData->usMRT.ucMinute,
                                                               pData->usMRT.ucSecond);
                (pData->usOT.ucMonth>12||pData->usOT.ucDay>31||pData->usOT.ucHour>23||pData->usOT.ucMinute>59||pData->usOT.ucSecond>59)?printf("发生时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("发生时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usOT.ucYear,
                                                               pData->usOT.ucMonth,
                                                               pData->usOT.ucDay,
                                                               pData->usOT.ucHour,
                                                               pData->usOT.ucMinute,
                                                               pData->usOT.ucSecond);
                (pData->usET.ucMonth>12||pData->usET.ucDay>31||pData->usET.ucHour>23||pData->usET.ucMinute>59||pData->usET.ucSecond>59)?printf("结束时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("结束时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usET.ucYear,
                                                               pData->usET.ucMonth,
                                                               pData->usET.ucDay,
                                                               pData->usET.ucHour,
                                                               pData->usET.ucMinute,
                                                               pData->usET.ucSecond);


            }
            break;

            case CMD_AFN_C_F645_ZFL_LTRO:
            {
                sMt20ZeroFireLineRecord* pData = (sMt20ZeroFireLineRecord*)puAppData;
                printf("最近一次指针： %d\n", pData->usLastPointer);
                printf("\n");
                if(pData->usLastPointer!=0){
                for(i = 0 ; i < pData->usLastPointer ; i++ ){
                   printf("第%d次零线电流： %7.3f\n",i+1,pData->usTotal[i].usZeroLineCurrent);
                   printf("第%d次火线电流： %7.3f\n",i+1,pData->usTotal[i].usFireLineCurrent);
                   (pData->usTotal[i].usReadTime.ucMonth>12||pData->usTotal[i].usReadTime.ucDay>31||pData->usTotal[i].usReadTime.ucHour>23||pData->usTotal[i].usReadTime.ucMinute>59||pData->usTotal[i].usReadTime.ucSecond>59)?printf("第%d次抄读时间: 错误日期(默认：2000年01月01日00时00分00秒)\n",i+1):
                    printf("第%d次抄读时间: %02d年%02d月%02d日%02d时%02d分%02d秒\n",i+1,pData->usTotal[i].usReadTime.ucYear,
                                                               pData->usTotal[i].usReadTime.ucMonth,
                                                               pData->usTotal[i].usReadTime.ucDay,
                                                               pData->usTotal[i].usReadTime.ucHour,
                                                               pData->usTotal[i].usReadTime.ucMinute,
                                                               pData->usTotal[i].usReadTime.ucSecond);
                    printf("\n");
 
                }
                }


            }
            break;

            case CMD_AFN_C_F646_L10TD_V:
             {sMtLast10VoltageData* pData = (sMtLast10VoltageData*)puAppData;
                
                printf("最近一次指针： %d\n", pData->usLastPointer);
                printf("\n");
                if(pData->usLastPointer!=0){
                for(i = 0 ; i <  pData->usLastPointer ; i++ ){
                   printf("第%d次A相电压： %5.1f\n",i+1,pData->usTotal[i].usAV);
                   printf("第%d次B相电压： %5.1f\n",i+1,pData->usTotal[i].usBV);
                   printf("第%d次C相电压： %5.1f\n",i+1,pData->usTotal[i].usCV);
                   (pData->usTotal[i].usReadTime.ucMonth>12||pData->usTotal[i].usReadTime.ucDay>31||pData->usTotal[i].usReadTime.ucHour>23||pData->usTotal[i].usReadTime.ucMinute>59||pData->usTotal[i].usReadTime.ucSecond>59)?printf("第%d次抄读时间: 错误日期(默认：2000年01月01日00时00分00秒)\n",i+1):
                    printf("第%d次抄读时间: %02d年%02d月%02d日%02d时%02d分%02d秒\n",i+1,pData->usTotal[i].usReadTime.ucYear,
                                                               pData->usTotal[i].usReadTime.ucMonth,
                                                               pData->usTotal[i].usReadTime.ucDay,
                                                               pData->usTotal[i].usReadTime.ucHour,
                                                               pData->usTotal[i].usReadTime.ucMinute,
                                                               pData->usTotal[i].usReadTime.ucSecond);
                    printf("\n");
                    }
                }
             }
            break;

            case CMD_AFN_C_F647_L10OD_WM:
            {
                    sMtWattMeters10Outages* pData = (sMtWattMeters10Outages*)puAppData;
                    (pData->usReadTime.ucMonth>12||pData->usReadTime.ucDay>31||pData->usReadTime.ucHour>23||pData->usReadTime.ucMinute>59||pData->usReadTime.ucSecond>59)?printf("抄读时间: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                    printf("抄读时间: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usReadTime.ucYear,
                                                               pData->usReadTime.ucMonth,
                                                               pData->usReadTime.ucDay,
                                                               pData->usReadTime.ucHour,
                                                               pData->usReadTime.ucMinute,
                                                               pData->usReadTime.ucSecond);
                    printf("\n");

                for(i = 0 ; i < 10 ; i++ ){
                   (pData->usTotal[i].usOutTime.ucMonth>12||pData->usTotal[i].usOutTime.ucDay>31||pData->usTotal[i].usOutTime.ucHour>23||pData->usTotal[i].usOutTime.ucMinute>59||pData->usTotal[i].usOutTime.ucSecond>59)?printf("电能表上%d次停电时间: 错误日期(默认：2000年01月01日00时00分00秒)\n",i+1):
                    printf("电能表上%d次停电时间: %02d年%02d月%02d日%02d时%02d分%02d秒\n",i+1,pData->usTotal[i].usOutTime.ucYear,
                                                               pData->usTotal[i].usOutTime.ucMonth,
                                                               pData->usTotal[i].usOutTime.ucDay,
                                                               pData->usTotal[i].usOutTime.ucHour,
                                                               pData->usTotal[i].usOutTime.ucMinute,
                                                               pData->usTotal[i].usOutTime.ucSecond);
                    (pData->usTotal[i].usInputTime.ucMonth>12||pData->usTotal[i].usInputTime.ucDay>31||pData->usTotal[i].usInputTime.ucHour>23||pData->usTotal[i].usInputTime.ucMinute>59||pData->usTotal[i].usInputTime.ucSecond>59)?printf("电能表上%d次上电时间: 错误日期(默认：2000年01月01日00时00分00秒)\n",i+1):
                    printf("电能表上%d次上电时间: %02d年%02d月%02d日%02d时%02d分%02d秒\n",i+1,pData->usTotal[i].usInputTime.ucYear,
                                                               pData->usTotal[i].usInputTime.ucMonth,
                                                               pData->usTotal[i].usInputTime.ucDay,
                                                               pData->usTotal[i].usInputTime.ucHour,
                                                               pData->usTotal[i].usInputTime.ucMinute,
                                                               pData->usTotal[i].usInputTime.ucSecond);
                    printf("\n");
 
                }


            }
            break;

            case CMD_AFN_C_F649_LVLA_RB:
            {
                sMtAPhaseLossVRecord* pData = (sMtAPhaseLossVRecord*)puAppData;
                (pData->usMRT.ucMonth>12||pData->usMRT.ucDay>31||pData->usMRT.ucHour>23||pData->usMRT.ucMinute>59||pData->usMRT.ucSecond>59)?printf("抄表时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usMRT.ucYear,
                                                               pData->usMRT.ucMonth,
                                                               pData->usMRT.ucDay,
                                                               pData->usMRT.ucHour,
                                                               pData->usMRT.ucMinute,
                                                               pData->usMRT.ucSecond);
                (pData->usTLTPAO.ucMonth>12||pData->usTLTPAO.ucDay>31||pData->usTLTPAO.ucHour>23||pData->usTLTPAO.ucMinute>59||pData->usTLTPAO.ucSecond>59)?printf("上一次A相发生时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("上一次A相发生时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usTLTPAO.ucYear,
                                                               pData->usTLTPAO.ucMonth,
                                                               pData->usTLTPAO.ucDay,
                                                               pData->usTLTPAO.ucHour,
                                                               pData->usTLTPAO.ucMinute,
                                                               pData->usTLTPAO.ucSecond);
                pData->usTTPPATTOPALOV>1000000?printf("\tA相失压发生时刻正向有功总电能: 数值超出范围 kWh\n"):
                printf("\tA相失压发生时刻正向有功总电能: %9.2f kWh\n",pData->usTTPPATTOPALOV);
                pData->usTEEORAPATTOPALOF>1000000?printf("\tA相失压发生时刻反向有功总电能: 数值超出范围 kWh\n"):
                printf("\tA相失压发生时刻反向有功总电能: %9.2f kWh\n",pData->usTEEORAPATTOPALOF);
               
                (pData->usET.ucMonth>12||pData->usET.ucDay>31||pData->usET.ucHour>23||pData->usET.ucMinute>59||pData->usET.ucSecond>59)?printf("结束时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("结束时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usET.ucYear,
                                                               pData->usET.ucMonth,
                                                               pData->usET.ucDay,
                                                               pData->usET.ucHour,
                                                               pData->usET.ucMinute,
                                                               pData->usET.ucSecond);
                
                pData->usTPPATEOPALOV>1000000?printf("\tA相失压结束时刻正向有功总电能: 数值超出范围 kWh\n"):
                printf("\tA相失压结束时刻正向有功总电能: %9.2f kWh\n",pData->usTPPATEOPALOV);
                pData->usTEORAPATEOPALOV>1000000?printf("\tA相失压结束时刻反向有功总电能: 数值超出范围 kWh\n"):
                printf("\tA相失压结束时刻反向有功总电能: %9.2f kWh\n",pData->usTEORAPATEOPALOV);
            }
            break;

            case CMD_AFN_C_F650_LVLB_RB:
            {
                sMtBPhaseLossVRecord* pData = (sMtBPhaseLossVRecord*)puAppData;
                (pData->usMRT.ucMonth>12||pData->usMRT.ucDay>31||pData->usMRT.ucHour>23||pData->usMRT.ucMinute>59||pData->usMRT.ucSecond>59)?printf("抄表时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usMRT.ucYear,
                                                               pData->usMRT.ucMonth,
                                                               pData->usMRT.ucDay,
                                                               pData->usMRT.ucHour,
                                                               pData->usMRT.ucMinute,
                                                               pData->usMRT.ucSecond);
                (pData->usTLTPBO.ucMonth>12||pData->usTLTPBO.ucDay>31||pData->usTLTPBO.ucHour>23||pData->usTLTPBO.ucMinute>59||pData->usTLTPBO.ucSecond>59)?printf("上一次B相发生时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("上一次B相发生时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usTLTPBO.ucYear,
                                                               pData->usTLTPBO.ucMonth,
                                                               pData->usTLTPBO.ucDay,
                                                               pData->usTLTPBO.ucHour,
                                                               pData->usTLTPBO.ucMinute,
                                                               pData->usTLTPBO.ucSecond);
                pData->usTTPPATTOPBLOV>1000000?printf("\tB相失压发生时刻正向有功总电能: 数值超出范围 kWh\n"):
                printf("\tB相失压发生时刻正向有功总电能: %9.2f kWh\n",pData->usTTPPATTOPBLOV);
                pData->usTEEORAPATTOPBLOF>1000000?printf("\tB相失压发生时刻反向有功总电能: 数值超出范围 kWh\n"):
                printf("\tB相失压发生时刻反向有功总电能: %9.2f kWh\n",pData->usTEEORAPATTOPBLOF);
               
                (pData->usET.ucMonth>12||pData->usET.ucDay>31||pData->usET.ucHour>23||pData->usET.ucMinute>59||pData->usET.ucSecond>59)?printf("结束时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("结束时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usET.ucYear,
                                                               pData->usET.ucMonth,
                                                               pData->usET.ucDay,
                                                               pData->usET.ucHour,
                                                               pData->usET.ucMinute,
                                                               pData->usET.ucSecond);
                
                pData->usTPPATEOPBLOV>1000000?printf("\tB相失压结束时刻正向有功总电能: 数值超出范围 kWh\n"):
                printf("\tB相失压结束时刻正向有功总电能: %9.2f kWh\n",pData->usTPPATEOPBLOV);
                pData->usTEORAPATEOPBLOV>1000000?printf("\tB相失压结束时刻反向有功总电能: 数值超出范围 kWh\n"):
                printf("\tB相失压结束时刻反向有功总电能: %9.2f kWh\n",pData->usTEORAPATEOPBLOV);
            }
            break;

            case CMD_AFN_C_F651_LVLC_RB:
            {
                sMtCPhaseLossVRecord* pData = (sMtCPhaseLossVRecord*)puAppData;
                (pData->usMRT.ucMonth>12||pData->usMRT.ucDay>31||pData->usMRT.ucHour>23||pData->usMRT.ucMinute>59||pData->usMRT.ucSecond>59)?printf("抄表时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usMRT.ucYear,
                                                               pData->usMRT.ucMonth,
                                                               pData->usMRT.ucDay,
                                                               pData->usMRT.ucHour,
                                                               pData->usMRT.ucMinute,
                                                               pData->usMRT.ucSecond);
                (pData->usTLTPCO.ucMonth>12||pData->usTLTPCO.ucDay>31||pData->usTLTPCO.ucHour>23||pData->usTLTPCO.ucMinute>59||pData->usTLTPCO.ucSecond>59)?printf("上一次C相发生时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("上一次B相发生时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usTLTPCO.ucYear,
                                                               pData->usTLTPCO.ucMonth,
                                                               pData->usTLTPCO.ucDay,
                                                               pData->usTLTPCO.ucHour,
                                                               pData->usTLTPCO.ucMinute,
                                                               pData->usTLTPCO.ucSecond);
                pData->usTTPPATTOPCLOV>1000000?printf("\tC相失压发生时刻正向有功总电能: 数值超出范围 kWh\n"):
                printf("\tC相失压发生时刻正向有功总电能: %9.2f kWh\n",pData->usTTPPATTOPCLOV);
                pData->usTEEORAPATTOPCLOF>1000000?printf("\tC相失压发生时刻反向有功总电能: 数值超出范围 kWh\n"):
                printf("\tC相失压发生时刻反向有功总电能: %9.2f kWh\n",pData->usTEEORAPATTOPCLOF);
               
                (pData->usET.ucMonth>12||pData->usET.ucDay>31||pData->usET.ucHour>23||pData->usET.ucMinute>59||pData->usET.ucSecond>59)?printf("结束时刻: 错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("结束时刻: %02d年%02d月%02d日%02d时%02d分%02d秒\n",pData->usET.ucYear,
                                                               pData->usET.ucMonth,
                                                               pData->usET.ucDay,
                                                               pData->usET.ucHour,
                                                               pData->usET.ucMinute,
                                                               pData->usET.ucSecond);
                
                pData->usTPPATEOPCLOV>1000000?printf("\tC相失压结束时刻正向有功总电能: 数值超出范围 kWh\n"):
                printf("\tC相失压结束时刻正向有功总电能: %9.2f kWh\n",pData->usTPPATEOPCLOV);
                pData->usTEORAPATEOPCLOV>1000000?printf("\tC相失压结束时刻反向有功总电能: 数值超出范围 kWh\n"):
                printf("\tC相失压结束时刻反向有功总电能: %9.2f kWh\n",pData->usTEORAPATEOPCLOV);
            }
            break;

            case CMD_AFN_D_F97_CURVE_FRTH_HAVE:
            {
                sMtAfn0dF97 *psU = (sMtAfn0dF97*)puAppData;
                UINT8       i;
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTd_c.sT.ucYY
                                                         ,psU->sTd_c.sT.ucMM
                                                         ,psU->sTd_c.sT.ucDD
                                                         ,psU->sTd_c.sT.ucHH
                                                         ,psU->sTd_c.sT.ucmm);

                for (i = 0; i < psU->sTd_c.ucN;i++)
                {
                    printf("有功电能量%d  = %0.4f\n",i+1,psU->dEnergy[i]);
                }
            }
            break;

            case CMD_AFN_D_F101_CURVE_FRTH_HAVE:
            {
                sMtAfn0dF101 *psU = (sMtAfn0dF101*)puAppData;
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTd_c.sT.ucYY
                                                         ,psU->sTd_c.sT.ucMM
                                                         ,psU->sTd_c.sT.ucDD
                                                         ,psU->sTd_c.sT.ucHH
                                                         ,psU->sTd_c.sT.ucmm);

                for (i = 0; i < psU->sTd_c.ucN;i++)
                {
                    printf("有功电能量%d  = %0.2f\n",i+1,psU->dValue[i]);
                }
            }
            break;

            case CMD_AFN_D_F105_CURVE_FACTOR_T:
            {
                sMtAfn0dF105 *psU = (sMtAfn0dF105*)puAppData;
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTd_c.sT.ucYY
                                                         ,psU->sTd_c.sT.ucMM
                                                         ,psU->sTd_c.sT.ucDD
                                                         ,psU->sTd_c.sT.ucHH
                                                         ,psU->sTd_c.sT.ucmm);

                for (i = 0; i < psU->sTd_c.ucN;i++)
                {
                    printf("测试点功率因数%d  = %0.1f\n",i+1,psU->fFactor[i]);
                }
            }
            break;
            
            case CMD_AFN_D_F109_ANGLE_CURVE_VOLT:
            {
                sMtAfn0dF109 *psU = (sMtAfn0dF109*)puAppData;
                UINT8       i;
                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTd_c.sT.ucYY
                                                         ,psU->sTd_c.sT.ucMM
                                                         ,psU->sTd_c.sT.ucDD
                                                         ,psU->sTd_c.sT.ucHH
                                                         ,psU->sTd_c.sT.ucmm);

                for (i = 0; i < psU->sTd_c.ucN;i++)
                {
                    printf("相位角%d A = %0.1f\n",i+1,psU->sPhase[i].fPhaseA);
                    printf("相位角%d B = %0.1f\n",i+1,psU->sPhase[i].fPhaseA);
                    printf("相位角%d C = %0.1f\n",i+1,psU->sPhase[i].fPhaseA);
                }
            }
            break;

            case CMD_AFN_D_F113_ELEC_HARM_TIME_A:
            {
                sMtAfn0dF113 *psU = (sMtAfn0dF113*)puAppData;
                printf("抄表时间 %d年%d月%d日\n" ,psU->sTd_d.sT.ucYY
                                             ,psU->sTd_d.sT.ucMM
                                             ,psU->sTd_d.sT.ucDD);

                for (i = 0; i < MT_AFN0DF113_COUNT - 1;i++)
                {
                    printf("A相 %d次谐波电流日最大值 %.2f\n",i+2,psU->sHarmTime[i].fHarmI);
                    printf("A相 %d次谐波电流发生在 %d月%d日  %d时%d分\n",i+2
                                                                        ,psU->sHarmTime[i].sTime.ucMM
                                                                        ,psU->sHarmTime[i].sTime.ucDD
                                                                        ,psU->sHarmTime[i].sTime.ucHH
                                                                        ,psU->sHarmTime[i].sTime.ucmm);
                    
                }

                 printf("A相总畸变电流日最大值 %.2f\n",psU->sHarmTime[i].fHarmI);
                 printf("A相总畸变电流发生在 %d月%d日  %d时%d分\n" ,psU->sHarmTime[i].sTime.ucMM
                                                                   ,psU->sHarmTime[i].sTime.ucDD
                                                                   ,psU->sHarmTime[i].sTime.ucHH
                                                                   ,psU->sHarmTime[i].sTime.ucmm);
            }
            break;

            case CMD_AFN_D_F116_VOLT_HARM_TIME_A:
            {
                sMtAfn0dF116 *psU = (sMtAfn0dF116*)puAppData;
                printf("抄表时间 %d年%d月%d日\n" ,psU->sTd_d.sT.ucYY
                                             ,psU->sTd_d.sT.ucMM
                                             ,psU->sTd_d.sT.ucDD);

                for (i = 0; i < MT_AFN0DF113_COUNT - 1;i++)
                {
                    printf("A相 %d次谐波电压日最大值 %.1f\n",i+2,psU->sHarmTime[i].fHarmU);
                    printf("A相 %d次谐波电压发生在 %d月%d日  %d时%d分\n",i+2
                                                                        ,psU->sHarmTime[i].sTime.ucMM
                                                                        ,psU->sHarmTime[i].sTime.ucDD
                                                                        ,psU->sHarmTime[i].sTime.ucHH
                                                                        ,psU->sHarmTime[i].sTime.ucmm);
                    
                }

                 printf("A相总畸变电压日最大值 %.1f\n",psU->sHarmTime[i].fHarmU);
                 printf("A相总畸变电压发生在 %d月%d日  %d时%d分\n" ,psU->sHarmTime[i].sTime.ucMM
                                                                   ,psU->sHarmTime[i].sTime.ucDD
                                                                   ,psU->sHarmTime[i].sTime.ucHH
                                                                   ,psU->sHarmTime[i].sTime.ucmm);
            }
            break;

            case CMD_AFN_D_F121_HARM_OVER_A:
            {
                sMtAfn0dF121 *psU = (sMtAfn0dF121*)puAppData;
                printf("抄表时间 %d年%d月%d日\n" ,psU->sTd_d.sT.ucYY
                                             ,psU->sTd_d.sT.ucMM
                                             ,psU->sTd_d.sT.ucDD);
                                             

                printf("谐波次数 %d\n",psU->ucN);
                printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");        
                printf("总畸变电压含有率越限日累计时间 %d\n",psU->usUAbnormal);
                for(i = 0; i < psU->ucN;i++)
                {
                    printf("%d 次谐波电压含有率越限日累计时间 %d\n",i+2,psU->usUHarm[i]);
                }
                
                printf("\n总畸变电流含有率越限日累计时间 %d\n",psU->usIAbnormal);
                for(i = 0; i < psU->ucN;i++)
                {
                    printf("%d 次谐波电流含有率越限日累计时间 %d\n",i+2,psU->usIHarm[i]);
                }
            }
            break;

            case CMD_AFN_D_F161_HAVE_FRTH_D:
            {
                sMtAfn0dF161* psU = (sMtAfn0dF161*)puAppData;
                printf("日冻结类数据时标Td_d:%d年%d月%d日\n", psU->sTd_d.sT.ucYY, psU->sTd_d.sT.ucMM, psU->sTd_d.sT.ucDD);
                printf("终端抄表时间:%d年%d月%d日 %d时%d分\n", psU->sTime.ucYY, psU->sTime.ucMM, psU->sTime.ucDD, psU->sTime.ucHH, psU->sTime.ucmm);
                printf("费率数M(个):%d\n", psU->ucM);
                printf("正向有功总电能示值(kWh):%7.4f\n", psU->totalValue);
                /*for (i = 0; i < psU->ucM; i++) {
                    if (psU->dValue[i] == 1555555.555400) {
                        printf("费率%d有功电能示值(kWh):N/A\n", i + 1);
                    }
                    else {
                        printf("费率%d有功电能示值(kWh):%7.4f\n", i + 1, psU->dValue[i]);
                    }
                }*/
            }
            break;


            case CMD_AFN_D_F169_HAVE_FRTH_R:
            {
                sMtAfn0dF169 *psU = (sMtAfn0dF169*)puAppData;
                printf("冻结时标 %d年%d月\n" ,psU->sTd_m.sT.ucYY
                                             ,psU->sTd_m.sT.ucMM);
                                             

                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTime.ucYY
                                                         ,psU->sTime.ucMM
                                                         ,psU->sTime.ucDD
                                                         ,psU->sTime.ucHH
                                                         ,psU->sTime.ucmm);
                                                         
                printf("A相正向有功电能示值 %.4f\n",psU->dValueA);
                printf("B相正向有功电能示值 %.4f\n",psU->dValueB);
                printf("C相正向有功电能示值 %.4f\n",psU->dValueC);
                
            }
            break;

            case CMD_AFN_D_F170_NONE_FRTM_R:
            {
                sMtAfn0dF170 *psU = (sMtAfn0dF170*)puAppData;
                printf("冻结时标 %d年%d月%d日\n" ,psU->sTd_d.sT.ucYY
                                                 ,psU->sTd_d.sT.ucMM
                                                 ,psU->sTd_d.sT.ucDD);
                                             

                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTime.ucYY
                                                         ,psU->sTime.ucMM
                                                         ,psU->sTime.ucDD
                                                         ,psU->sTime.ucHH
                                                         ,psU->sTime.ucmm);
                printf("费率数 %d\n",psU->ucM);
                for(i = 0; i < psU->ucM; i++)
                {
                    printf("费率 %d 正向无功(组合无功)电能示值 %.2f\n",i+1,psU->dValue[i]);
                }
            }
            break;

            case CMD_AFN_D_F171_HAVE_BACK_R:
            {
                sMtAfn0dF171 *psU = (sMtAfn0dF171*)puAppData;
                printf("冻结时标 %d年%d月%d日\n" ,psU->sTd_d.sT.ucYY
                                                 ,psU->sTd_d.sT.ucMM
                                                 ,psU->sTd_d.sT.ucDD);
                                             

                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTime.ucYY
                                                         ,psU->sTime.ucMM
                                                         ,psU->sTime.ucDD
                                                         ,psU->sTime.ucHH
                                                         ,psU->sTime.ucmm);
                printf("费率数 %d\n",psU->ucM);
                for(i = 0; i < psU->ucM; i++)
                {
                    printf("费率 %d 有功电能示值 %.4f\n",i+1,psU->dValue[i]);
                }
            }
            break;

            case CMD_AFN_D_F177_HAVE_FRTH_M:
            {
                sMtAfn0dF177 *psU = (sMtAfn0dF177*)puAppData;
                printf("冻结时标 %d年%d月\n" ,psU->sTd_m.sT.ucYY
                                             ,psU->sTd_m.sT.ucMM);
                                             

                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTime.ucYY
                                                         ,psU->sTime.ucMM
                                                         ,psU->sTime.ucDD
                                                         ,psU->sTime.ucHH
                                                         ,psU->sTime.ucmm);
                printf("费率数 %d\n",psU->ucM);
                for(i = 0; i < psU->ucM; i++)
                {
                    printf("费率 %d 有功电能示值 %.4f\n",i+1,psU->dValue[i]);
                }
            }
            break;

            case CMD_AFN_D_F178_NONE_FRTM_M:
            {
                sMtAfn0dF178 *psU = (sMtAfn0dF178*)puAppData;
                UINT8       i;
                printf("冻结时标 %d年%d月\n" ,psU->sTd_m.sT.ucYY
                                             ,psU->sTd_m.sT.ucMM);
                                             

                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTime.ucYY
                                                         ,psU->sTime.ucMM
                                                         ,psU->sTime.ucDD
                                                         ,psU->sTime.ucHH
                                                         ,psU->sTime.ucmm);
                printf("费率数 %d\n",psU->ucM);
                for(i = 0; i < psU->ucM; i++)
                {
                    printf("费率 %d 无功(组合无功1)电能示值 %.2f\n",i+1,psU->dValue[i]);
                }
            }
            break;

            case CMD_AFN_D_F185_HAVE_DMND_FRTH_D:
            {
                sMtAfn0dF185 *psU = (sMtAfn0dF185*)puAppData;
                printf("冻结时标 %d年%d月%d日\n" ,psU->sTd_d.sT.ucYY
                                                 ,psU->sTd_d.sT.ucMM
                                                 ,psU->sTd_d.sT.ucDD);
                                             

                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTime.ucYY
                                                         ,psU->sTime.ucMM
                                                         ,psU->sTime.ucDD
                                                         ,psU->sTime.ucHH
                                                         ,psU->sTime.ucmm);
                printf("费率数 %d\n",psU->ucM);
                for(i = 0; i < psU->ucM + 1; i++)
                {
                    printf("最大需量 %.4f\n",psU->sMaxClock[i].fMax);
                    printf("最大需量发生时间 %d月%d日%d时%d分\n",psU->sMaxClock[i].sClock.ucMM
                                                                ,psU->sMaxClock[i].sClock.ucDD
                                                                ,psU->sMaxClock[i].sClock.ucHH
                                                                ,psU->sMaxClock[i].sClock.ucmm);
                    
                }
            }
            break;

            case CMD_AFN_D_F215_METR_BUY_USR:
            {
                sMtAfn0dF215 *psU = (sMtAfn0dF215*)puAppData;
                printf("冻结时标 %d年%d月\n" ,psU->sTd_m.sT.ucYY
                                             ,psU->sTd_m.sT.ucMM);
                                             

                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTime.ucYY
                                                         ,psU->sTime.ucMM
                                                         ,psU->sTime.ucDD
                                                         ,psU->sTime.ucHH
                                                         ,psU->sTime.ucmm);
                printf("购电次数 %d\n",psU->usBuyTimes);
                printf("剩余金额 %0.4f\n",psU->dCashLeft);
                printf("累计购电金额 %0.4f\n",psU->dCashTotal);
                printf("剩余电量 %0.2f\n",psU->dKilowattLeft);
                printf("透支电量 %0.2f\n",psU->dKilowattOver);
                printf("累计电量 %0.2f\n",psU->dKilowattTotal);
                printf("赊欠门电量 %0.2f\n",psU->dKilowattDebit);
                printf("告警电量 %0.2f\n",psU->dKilowattWarn);
                printf("故障电量 %0.2f\n",psU->dKilowattFault);
                
            }
            break;

            case CMD_AFN_D_F216_METR_BALANCE:
            {
                sMtAfn0dF216 *psU = (sMtAfn0dF216*)puAppData;
                printf("冻结时标 %d年%d月\n" ,psU->sTd_m.sT.ucYY
                                             ,psU->sTd_m.sT.ucMM);
                                             

                printf("抄表时间 %d年%d月%d日 %d时%d分\n",psU->sTime.ucYY
                                                         ,psU->sTime.ucMM
                                                         ,psU->sTime.ucDD
                                                         ,psU->sTime.ucHH
                                                         ,psU->sTime.ucmm);
                printf("已结有功功率总电能 %0.4f\n",psU->dTotalBalance);
                for(i = 0;i < psU->ucM;i++)
                {
                    printf("已结费率 %d有功功率总电能 %0.4f\n",i+1,psU->dBalance[i]); 
                }
                
                printf("\n未结有功功率总电能 %0.4f\n",psU->dTotalNoBalance);
                for(i = 0;i < psU->ucM;i++)
                {
                    printf("未结费率 %d有功功率总电能 %0.4f\n",i+1,psU->dNoBalance[i]); 
                }
                
                printf("\n故障电量 %0.4f\n",psU->dFault);
            }
            break;


            case CMD_AFN_D_F28_UBLN_OVER_D:
            {
                if(eDir == MT_DIR_S2M)
                {
                    sMtUblnOverD* psU = (sMtUblnOverD*)puAppData;
                    print_td_d(&psU->sTd_d);
                    printf("usCalElec = %d\n", psU->usCalElec);
                    printf("usCalVolt = %d\n", psU->usCalVolt);
                    printf("fMaxElec  = %f\n", psU->fMaxElec);
                    printf("sTimeMaxElec(DDHHmm) = %02d_%02d_%02d\n", 
                                               psU->sTimeMaxElec.ucDD,
                                               psU->sTimeMaxElec.ucHH,
                                               psU->sTimeMaxElec.ucmm);
                    printf("fMaxVolt  = %f\n", psU->fMaxVolt);
                    printf("sTimeMaxVolt(DDHHmm) = %02d_%02d_%02d\n", 
                                               psU->sTimeMaxVolt.ucDD,
                                               psU->sTimeMaxVolt.ucHH,
                                               psU->sTimeMaxVolt.ucmm);
                }
                else
                {
                   sMtTd_d * psU = (sMtTd_d*)puAppData;
                   print_td_d(psU);

                }
     
               
             }
            break;  

            case CMD_AFN_D_F625_EM_ABN_STATE:
            {
                sMtAfn0dF625* psU = (sMtAfn0dF625*)puAppData;
                printf("冻结时标 %02d年%02d月%02d日\n", psU->sTd_d.sT.ucYY
                    , psU->sTd_d.sT.ucMM
                    , psU->sTd_d.sT.ucDD);
                printf("总个数: %d\n", psU->allPoints);
                printf("本帧个数: %d\n", psU->framePoints);
                for (i = 0; i < psU->framePoints; i++) {
                    printf("第%d个电能表测量点: %d\n", i + 1, psU->sEachPointInfo[i].uEMPoint);
                    printf("第%d个电能表通信地址:", i + 1);
                    for (j = 5; j >= 0; j--) printf("%02x", psU->sEachPointInfo[i].uEMCommuAdd[j]);
                    printf("\n");
                    printf("发生异常类型个数: %d\n", psU->sEachPointInfo[i].uAbnTypes);
                    for (j = 0; j < psU->sEachPointInfo[i].uAbnTypes; j++) {
                        switch (psU->sEachPointInfo[i].eEachAbnInfo[j]) {
                        case ABN_OPEN_COVER: pStr = "开表盖";
                            break;
                        case ABN_ZERO_CURRENT: pStr = "零火线电流";
                            break;
                        case ABN_CONNECT_BACKWARD: pStr = "进出线接反";
                            break;
                        case ABN_INVERSE_PHASE: pStr = "三相表逆相序/单相表LN互逆";
                            break;
                        case ABN_CLOCK_VARIANCE: pStr = "时钟超差";
                            break;
                        case ABN_CLOCK_BATTERY_VOLTAGE: pStr = "时钟电池欠压";
                            break;
                        case ABN_LOSS_PRESSURE: pStr = "失压";
                            break;
                        case ABN_LOSS_CURRENT: pStr = "失流";
                            break;
                        case ABN_BROKEN_PHASE: pStr = "断相";
                            break;
                        case ABN_CURRENT_REVERS_PHASE: pStr = "三相表电流逆相序";
                            break;
                        case ABN_VOLTAGE_SERIES: pStr = "电压串线";
                            break;
                        case ABN_CURRENT_SERIES: pStr = "电流串线";
                            break;
                        case ABN_CONTINUOUS_NO_Freezing: pStr = "电能表连续无冻结";
                            break;
                        case ABN_METER_STOP: pStr = "电能表停走";
                            break;
                        case ABN_METER_FAST: pStr = "电能表飞走";
                            break;
                        case ABN_METER_TURNBACK: pStr = "电能表倒走";
                            break;
                        case ABN_UNEVEN_CHARGE: pStr = "电能表电量不平";
                            break;
                        case ABN_LEAKAGE: pStr = "火零线漏电异常";
                            break;
                        case ABN_NO_SAMPLED_WIRED: pStr = "零线电流不采样或未接线";
                            break;
                        case ABN_OVERVOLTAGE_ALARM: pStr = "光伏表过压告警";
                            break;
                        default: pStr = "未知异常";
                        }
                        printf("第%d个电能表的第%d个异常情况类型：%s\n\n", i + 1, j + 1, pStr);

                    }
                }

            }
            break;


            case CMD_AFN_D_F632_COPY_FAILED_STATIC:
            {
                sMtAfn0dF632* psU = (sMtAfn0dF632*)puAppData;
                (psU->sTd_d.sT.ucMM>12||psU->sTd_d.sT.ucDD>31)?printf("日冻结类数据时标Td_d: 错误日期(默认：2000年01月01日)\n"):
                printf("日冻结类数据时标Td_d：%02d年%02d月%02d日\n", psU->sTd_d.sT.ucYY
                    , psU->sTd_d.sT.ucMM
                    , psU->sTd_d.sT.ucDD);

                printf("总个数: %d\n", psU->uAllNums);
                printf("本帧个数: %d\n", psU->uFrameNums);
                for (i = 0; i < psU->uFrameNums; i++)
                {
                    printf("第%d个电能表测量点:%d\n", i + 1, psU->sEMDataForm[i].uMeasPoint);
                    printf("第%d个电能表电能表通信地址:", i + 1);
                    for (j = 5; j >= 0; j--) {
                        printf("%02x", psU->sEMDataForm[i].uAddress[j]);
                    }
                    printf("\n");
                    printf("第%d个电能表当日失败次数:%d\n\n", i + 1, psU->sEMDataForm[i].uDayFailed);
                }
            }
            break;

            case CMD_AFN_D_F633_RUN_STATE_WORD:
            {
                sMtAfn0dF633* psU = (sMtAfn0dF633*)puAppData;
                (psU->sTd_d.sT.ucMM>12||psU->sTd_d.sT.ucDD>31)?printf("日冻结类数据时标Td_d: 错误日期(默认：2000年01月01日)\n"):
                printf("日冻结类数据时标Td_d：%02d年%02d月%02d日\n", psU->sTd_d.sT.ucYY
                    , psU->sTd_d.sT.ucMM
                    , psU->sTd_d.sT.ucDD);
                (psU->sTime.ucMonth>12||psU->sTime.ucDay>31||psU->sTime.ucHour>23||psU->sTime.ucMinute>59||psU->sTime.ucSecond>59)?printf("抄表时间：错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄表时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n",
                    psU->sTime.ucYear,
                    psU->sTime.ucMonth,
                    psU->sTime.ucDay,
                    psU->sTime.ucHour,
                    psU->sTime.ucMinute,
                    psU->sTime.ucSecond);
                printf("运行状态字：");
                for (i = 13; i >= 0; i--)
                {
                    printf("%02X", psU->uRunStateWord[i]);
                }
            }
            break;

            case CMD_AFN_D_F634_LINE_CURRENT_ANAL:
            {
                sMtAfn0dF634* psU = (sMtAfn0dF634*)puAppData;
                (psU->sTd_d.sT.ucMM>12||psU->sTd_d.sT.ucDD>31)?printf("日冻结类数据时标Td_d: 错误日期(默认：2000年01月01日)\n"):
                printf("日冻结类数据时标Td_d：%02d年%02d月%02d日\n", psU->sTd_d.sT.ucYY
                    , psU->sTd_d.sT.ucMM
                    , psU->sTd_d.sT.ucDD);
                if(psU->ucN<=10){
                printf("个数：%d 个\n", psU->ucN);
                for (i = 0; i < psU->ucN; i++)
                {

                    printf("第%d次零线电流：%7.3f\n", i + 1, psU->sLineCurrentAnal[i].fZeroLineCur);
                    printf("第%d次火线电流：%7.3f\n", i + 1, psU->sLineCurrentAnal[i].fFireLineCur);
                    (psU->sLineCurrentAnal[i].sTime.ucMonth>12||psU->sLineCurrentAnal[i].sTime.ucDay>31||psU->sLineCurrentAnal[i].sTime.ucHour>23||psU->sLineCurrentAnal[i].sTime.ucMinute>59||psU->sLineCurrentAnal[i].sTime.ucSecond>59)?printf("抄表时间：错误日期(默认：2000年01月01日00时00分00秒)\n"):
                    printf("第%d次抄表时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n",i+1,
                        psU->sLineCurrentAnal[i].sTime.ucYear,
                        psU->sLineCurrentAnal[i].sTime.ucMonth,
                        psU->sLineCurrentAnal[i].sTime.ucDay,
                        psU->sLineCurrentAnal[i].sTime.ucHour,
                        psU->sLineCurrentAnal[i].sTime.ucMinute,
                        psU->sLineCurrentAnal[i].sTime.ucSecond);
                        printf("\n");
                }
                }else{
                    printf("个数：超过10个\n");
                }
                
            }
            break;

            case CMD_AFN_D_F635_OPEN_COVER_DATA:
            {
                sMtAfn0dF635* psU = (sMtAfn0dF635*)puAppData;
                (psU->sTd_d.sT.ucMM>12||psU->sTd_d.sT.ucDD>31)?printf("日冻结类数据时标Td_d: 错误日期(默认：2000年01月01日)\n"):
                printf("日冻结类数据时标Td_d：%02d年%02d月%02d日\n", psU->sTd_d.sT.ucYY
                    , psU->sTd_d.sT.ucMM
                    , psU->sTd_d.sT.ucDD);
                printf("开表盖总次数：");
                for (i = 2; i >= 0; i--) {
                    printf("%02x", psU->uallNums[i]);
                }
                printf("\n");
                if(psU->ucN<=10){
                printf("本轮次发生开表盖次数：%d\n", psU->ucN);
                for (i = 0; i < psU->ucN; i++)
                {
                    (psU->sOpenCover[i].sStartTime.ucMonth>12||psU->sOpenCover[i].sStartTime.ucDay>31||psU->sOpenCover[i].sStartTime.ucHour>23||psU->sOpenCover[i].sStartTime.ucMinute>59||psU->sOpenCover[i].sStartTime.ucSecond>59)?printf("抄表时间：错误日期(默认：2000年01月01日00时00分00秒)\n"):
                    printf("上%d次开表盖事件开始时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n",i+1,
                        psU->sOpenCover[i].sStartTime.ucYear,
                        psU->sOpenCover[i].sStartTime.ucMonth,
                        psU->sOpenCover[i].sStartTime.ucDay,
                        psU->sOpenCover[i].sStartTime.ucHour,
                        psU->sOpenCover[i].sStartTime.ucMinute,
                        psU->sOpenCover[i].sStartTime.ucSecond);
                    (psU->sOpenCover[i].sStopTime.ucMonth>12||psU->sOpenCover[i].sStopTime.ucDay>31||psU->sOpenCover[i].sStopTime.ucHour>23||psU->sOpenCover[i].sStopTime.ucMinute>59||psU->sOpenCover[i].sStopTime.ucSecond>59)?printf("抄表时间：错误日期(默认：2000年01月01日00时00分00秒)\n"):
                    printf("上%d次开表盖事件结束时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n\n",i+1,
                        psU->sOpenCover[i].sStopTime.ucYear,
                        psU->sOpenCover[i].sStopTime.ucMonth,
                        psU->sOpenCover[i].sStopTime.ucDay,
                        psU->sOpenCover[i].sStopTime.ucHour,
                        psU->sOpenCover[i].sStopTime.ucMinute,
                        psU->sOpenCover[i].sStopTime.ucSecond);
                        
                }
                }else{
                    printf("本轮次发生开表盖次数：超过10次\n\n");
                }
            }
            break;

            case CMD_AFN_D_F639_CLOCK_ERROR_DATA:
            {
                sMtAfn0dF639* psU = (sMtAfn0dF639*)puAppData;
                (psU->sTd_d.sT.ucMM>12||psU->sTd_d.sT.ucDD>31)?printf("日冻结类数据时标Td_d: 错误日期(默认：2000年01月01日)\n"):
                printf("日冻结类数据时标Td_d：%02d年%02d月%02d日\n", psU->sTd_d.sT.ucYY
                    , psU->sTd_d.sT.ucMM
                    , psU->sTd_d.sT.ucDD);
                (psU->sTime.ucMonth>12||psU->sTime.ucDay>31||psU->sTime.ucHour>23||psU->sTime.ucMinute>59||psU->sTime.ucSecond>59)?printf("抄读成功时间：错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("抄读成功时间：%02d年%02d月%02d日%02d时%02d分%02d秒\n",
                    psU->sTime.ucYear,
                    psU->sTime.ucMonth,
                    psU->sTime.ucDay,
                    psU->sTime.ucHour,
                    psU->sTime.ucMinute,
                    psU->sTime.ucSecond);

                (psU->sClock.ucMonth>12||psU->sClock.ucDay>31||psU->sClock.ucHour>23||psU->sClock.ucMinute>59||psU->sClock.ucSecond>59)?printf("电能表时钟：错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("电能表时钟：%02d年%02d月%02d日%02d时%02d分%02d秒\n",
                    psU->sClock.ucYear,
                    psU->sClock.ucMonth,
                    psU->sClock.ucDay,
                    psU->sClock.ucHour,
                    psU->sClock.ucMinute,
                    psU->sClock.ucSecond);
                printf("通信时长：%d s\n", psU->uComuPeriod);
                printf("电能表时钟误差值：%d s\n", psU->uClockError);
            }
            break;
            case CMD_AFN_D_F652_ALL_OVERLOAD_EVENT:
            {
                sMtAfn0dF652* psU = (sMtAfn0dF652*)puAppData;
                (psU->sTd_d.sT.ucMM>12||psU->sTd_d.sT.ucDD>31)?printf("日冻结类数据时标Td_d: 错误日期(默认：2000年01月01日)\n"):
                printf("日冻结类数据时标Td_d：%02d年%02d月%02d日\n", psU->sTd_d.sT.ucYY
                    , psU->sTd_d.sT.ucMM
                    , psU->sTd_d.sT.ucDD);
                printf("过流总次数：");
                for (i = 2; i >= 0; i--) printf("%02X", psU->uallNums[i]);
                printf(" 次\n");
                printf("上次过流总次数：");
                for (i = 2; i >= 0; i--) printf("%02X", psU->uLastNums[i]);
                printf(" 次\n");
                printf("过流总累计时间：");
                for (i = 2; i >= 0; i--) printf("%02X", psU->uallTimes[i]);
                printf(" 分\n");
                (psU->sStartTime.ucMonth>12||psU->sStartTime.ucDay>31||psU->sStartTime.ucHour>23||psU->sStartTime.ucMinute>59||psU->sStartTime.ucSecond>59)?printf("最近 1 次过流发生时刻：错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("最近 1 次过流发生时刻：%02d年%02d月%02d日%02d时%02d分%02d秒\n",
                    psU->sStartTime.ucYear,
                    psU->sStartTime.ucMonth,
                    psU->sStartTime.ucDay,
                    psU->sStartTime.ucHour,
                    psU->sStartTime.ucMinute,
                    psU->sStartTime.ucSecond);
                (psU->sStopClock.ucMonth>12||psU->sStopClock.ucDay>31||psU->sStopClock.ucHour>23||psU->sStopClock.ucMinute>59||psU->sStopClock.ucSecond>59)?printf("最近 1 次过流结束时刻：错误日期(默认：2000年01月01日00时00分00秒)\n"):
                printf("最近 1 次过流结束时刻：%02d年%02d月%02d日%02d时%02d分%02d秒\n",
                    psU->sStopClock.ucYear,
                    psU->sStopClock.ucMonth,
                    psU->sStopClock.ucDay,
                    psU->sStopClock.ucHour,
                    psU->sStopClock.ucMinute,
                    psU->sStopClock.ucSecond);
            }
            break;

            case CMD_AFN_D_F653_PHASEA_OVERLOAD_EVENT:
            {
                sMtAfn0dF653* psU = (sMtAfn0dF653*)puAppData;
                (psU->sTd_d.sT.ucMM>12||psU->sTd_d.sT.ucDD>31)?printf("日冻结类数据时标Td_d: 错误日期(默认：2000年01月01日)\n"):
                printf("日冻结类数据时标Td_d:%02d年%02d月%02d日\n", psU->sTd_d.sT.ucYY
                    , psU->sTd_d.sT.ucMM
                    , psU->sTd_d.sT.ucDD);
                printf("A相过流总次数:");
                for (i = 2; i >= 0; i--) printf("%02X", psU->uallNums[i]);
                printf(" 次\n");
                printf("A相过流总累计时间:");
                for (i = 2; i >= 0; i--) printf("%02X", psU->uallTimes[i]);
                printf(" 次\n");
                printf("本次抄读个数:%d 次\n\n", psU->ucN);
                for (i = 0; i < 5; i++) {
                    (psU->sOverLoadInfo[i].sStartTime.ucMonth>12||psU->sOverLoadInfo[i].sStartTime.ucDay>31||psU->sOverLoadInfo[i].sStartTime.ucHour>23||psU->sOverLoadInfo[i].sStartTime.ucMinute>59||psU->sOverLoadInfo[i].sStartTime.ucSecond>59)?printf("(上 %d 次)A 相失流发生时刻：错误日期(默认：2000年01月01日00时00分00秒)\n",i+1):
                    printf("(上 %d 次)A 相失流发生时刻：%02d年%02d月%02d日%02d时%02d分%02d秒\n", i + 1,
                        psU->sOverLoadInfo[i].sStartTime.ucYear,
                        psU->sOverLoadInfo[i].sStartTime.ucMonth,
                        psU->sOverLoadInfo[i].sStartTime.ucDay,
                        psU->sOverLoadInfo[i].sStartTime.ucHour,
                        psU->sOverLoadInfo[i].sStartTime.ucMinute,
                        psU->sOverLoadInfo[i].sStartTime.ucSecond);
                    printf("(上 %d 次)A相过流发生时刻正向有功总电能:%9.3f kWh\n", i + 1, psU->sOverLoadInfo[i].dPosiAllEnergy);
                    printf("(上 %d 次)A相过流发生时刻反向有功总电能:%9.3f kWh\n", i + 1, psU->sOverLoadInfo[i].dNegAllEnergy);
                    printf("(上 %d 次)A相过流发生时刻A相正向有功电能:%9.3f kWh\n", i + 1, psU->sOverLoadInfo[i].dAPosiAllEnergy);
                    printf("(上 %d 次)A相过流发生时刻A相反向有功电能:%9.3f kWh\n", i + 1, psU->sOverLoadInfo[i].dANegAllEnergy);
                    printf("(上 %d 次)A相过流发生时刻A相电流:%7.3f A\n", i + 1, psU->sOverLoadInfo[i].fACurrent);
                    (psU->sOverLoadInfo[i].sStopTime.ucMonth>12||psU->sOverLoadInfo[i].sStopTime.ucDay>31||psU->sOverLoadInfo[i].sStopTime.ucHour>23||psU->sOverLoadInfo[i].sStopTime.ucMinute>59||psU->sOverLoadInfo[i].sStopTime.ucSecond>59)?printf("(上 %d 次)A 相失流结束时刻：错误日期(默认：2000年01月01日00时00分00秒)\n",i+1):
                    printf("(上 %d 次)A 相失流结束时刻：%02d年%02d月%02d日%02d时%02d分%02d秒\n\n", i + 1,
                        psU->sOverLoadInfo[i].sStopTime.ucYear,
                        psU->sOverLoadInfo[i].sStopTime.ucMonth,
                        psU->sOverLoadInfo[i].sStopTime.ucDay,
                        psU->sOverLoadInfo[i].sStopTime.ucHour,
                        psU->sOverLoadInfo[i].sStopTime.ucMinute,
                        psU->sOverLoadInfo[i].sStopTime.ucSecond);
                }

            }
            break;

#if 0

            case CMD_AFN_4_FN_33_CFG_NOT_ELEC:
            {
                sMtCfgNotElec *psUser  =(sMtCfgNotElec*)puAppData;

                switch(psUser->eType)
                {
                    case MT_NELEC_TEMP:
                        pStr = "MT_NELEC_TEMP 温度";
                        break;
                    case MT_NELEC_FLOW:
                        pStr = "MT_NELEC_FLOW 流量";
                        break;
                    case MT_NELEC_FLOW_V:
                        pStr = "MT_NELEC_FLOW_V 流速";
                        break;
                    case MT_NELEC_PRESS:
                        pStr = "MT_NELEC_PRESS 压力";
                        break;
                    case MT_NELEC_HUMID:
                        pStr = "MT_NELEC_HUMID 湿度";
                        break;
                    case MT_NELEC_ILLUM:
                        pStr = "MT_NELEC_ILLUM 照度";
                        break;
                    case MT_NELEC_ROTATE:
                        pStr = "MT_NELEC_ROTATE 转速";
                        break;
                    default:
                        pStr = "未知类型";
                        break;
                }
    
                printf("eType =  %s\n", pStr);
                printf("dMin  =  %lf\n", psUser->dMin);
                printf("dMax  =  %lf\n", psUser->dMax);
            }
            break;

            case CMD_AFN_C_FN_90_NOT_ELEC:
                {
                    sMtNotElec *psUser  =(sMtNotElec*)puAppData;
                    switch(psUser->eType)
                    {
                        case MT_NELEC_TEMP:
                            pStr = "MT_NELEC_TEMP 温度";
                            break;
                        case MT_NELEC_FLOW:
                            pStr = "MT_NELEC_FLOW 流量";
                            break;
                        case MT_NELEC_FLOW_V:
                            pStr = "MT_NELEC_FLOW_V 流速";
                            break;
                        case MT_NELEC_PRESS:
                            pStr = "MT_NELEC_PRESS 压力";
                            break;
                        case MT_NELEC_HUMID:
                            pStr = "MT_NELEC_HUMID 湿度";
                            break;
                        case MT_NELEC_ILLUM:
                            pStr = "MT_NELEC_ILLUM 照度";
                            break;
                        case MT_NELEC_ROTATE:
                            pStr = "MT_NELEC_ROTATE 转速";
                            break;
                        default:
                            pStr = "未知类型";
                            break;
                    }
    
                    printf("Type  =  %s\n",  pStr);
                    printf("Value =  %lf\n", psUser->dValue);

                }
                break;

          #endif


    

            default:
            {
                show_error("没有数据域,或未实现显示\n");
            }

            break;





    }
}
/*****************************************************************************
 函 数 名  : show_app_data
 功能描述  : 显示应用层数据
 输入参数  : smtSub *pSub  
 输出参数  : 无
 返 回 值  : 
 调用函数  : 
 被调函数  : 
 
 修改历史      :
  1.日    期   : 2013年4月27日 星期六
    作    者   : liming
    修改内容   : 新生成函数

*****************************************************************************/
void show_app_data_adp(eMtDir eDir, sCmSub *pSub)
{
    if(!pSub)
    {
        return;
    }

    sMtCmdInfor    sCmdInfor   = {0};
    eMtErr         eRet        = MT_OK;    
   // pMtFunc        pFunc       = NULL;
    char *         pStr        = NULL;
    eMtCmd         emtCmd  ;

    pStr = NULL;
    
   emtCmd =  eGetMtCmd(pSub->eCmd);
   // sub cmd
   printf("sCmd  = %06X\t", emtCmd);
   show_sub_name("子命令ID\t");
   eRet = eMtGetCmdInfor(emtCmd, eDir, &sCmdInfor);
   if(eRet != MT_OK)
   {
        show_error("错误的命令类型!");
        return;
   }
   else
   {
        show_item_value(sCmdInfor.pName);
   }
   printf("\n");

   //pn 
   printf("usPN  = %d\t", pSub->usPN);
   show_sub_name("信息点PN\t");
   switch(sCmdInfor.ePn)
   {
       case MT_PN_P0:
        show_item_value("PN无关");
        break;
       case MT_PN_TM:
        show_item_value("终端号");
        break;
       case MT_PN_MP:
        show_item_value("测量点号");
        break;
       case MT_PN_GT:
        show_item_value("总加组号");
        break;
       case MT_PN_CT:
        show_item_value("控制轮次");
        break;
       case MT_PN_TK:
        show_item_value("任务号");
        break;
       case MT_PN_DP:
        show_item_value("直流模拟量端口号");
        break;
        
       default:
        show_error("未知PN 类型");
        break;
   }

    if( pSub->bApp != TRUE)
    {
        show_sub_name("\n无数据单元\t");
    }
  
    
    // 应用层数据
    if(sCmdInfor.pFunc == NULL)
    {
       show_item_value("无数据单元\n");
       return;

    }

    show_main_name("\n数据单元:\n");
    // 有应用层数据

    char buf[1024] = {0};
    uMtApp *pmtAppData = (uMtApp *)buf;
    emtTransAppData_cm_2_mt(emtCmd, &(pSub->uAppData), pmtAppData);
    show_app_sub_data(eDir, emtCmd, pmtAppData);
}





/*****************************************************************************
 函 数 名  : show_app_data
 功能描述  : 显示应用层数据
 输入参数  : smtSub *pSub  
 输出参数  : 无
 返 回 值  : 
 调用函数  : 
 被调函数  : 
 
 修改历史      :
  1.日    期   : 2013年4月27日 星期六
    作    者   : liming
    修改内容   : 新生成函数

*****************************************************************************/
void show_app_data(eMtDir eDir, sMtData *pSub)
{
   if(!pSub)
   {
      return;
   }


    sMtCmdInfor    sCmdInfor   = {0};
    eMtErr         eRet        = MT_OK;    
    // pMtFunc   pFunc       = NULL;
    //char *         pStr        = NULL;

   
   // sub cmd
   printf("sCmd  = 0X%06X\t", pSub->eCmd);
   show_sub_name("子命令ID\t");
   eRet = eMtGetCmdInfor(pSub->eCmd, eDir, &sCmdInfor);
   if(eRet != MT_OK)
   {
        show_error("错误的命令类型!");
        return;
   }
   else
   {
        show_item_value(sCmdInfor.pName);
   }
   printf("\n");

   //pn 
   printf("usPN  = P%d\t", pSub->usPN);
   show_sub_name("信息点PN\t");
   switch(sCmdInfor.ePn)
   {
       case MT_PN_P0:
        show_item_value("PN无关");
        break;
       case MT_PN_TM:
        show_item_value("终端号");
        break;
       case MT_PN_MP:
        show_item_value("测量点号");
        break;
       case MT_PN_GT:
        show_item_value("总加组号");
        break;
       case MT_PN_CT:
        show_item_value("控制轮次");
        break;
       case MT_PN_TK:
        show_item_value("任务号");
        break;
       case MT_PN_DP:
        show_item_value("直流模拟量端口号");
        break;
        
       default:
        show_error("未知PN 类型");
        break;
   }
   

      // 应用层数据
    if(sCmdInfor.pFunc == NULL)
    {
       show_item_value("无数据单元\n");
       return;

    }
    
    // 应用层数据
    if(sCmdInfor.pFunc == NULL)
    {
       show_item_value("无数据单元\n");
       return;

    }

    show_main_name("\n数据单元:\n");
    // 有应用层数据
    show_app_sub_data(eDir, pSub->eCmd, &(pSub->uApp));
    
}


void show_pack_adp(sCmPacket * psUnpack)
{
    if(!psUnpack)
    {
        printf("psUnpack is null\n");
        return;
    }

   
   // char *str = NULL;
    char str_reg[5] = {0};
    char strTmp[128] = {0};
    int i = 0;
    int nSubNum = 0;
    eMtDir eDir = MT_DIR_M2S;

    // 输出地址信息
    show_main_name("address:\n");
    memcpy(str_reg,psUnpack->sAddress.acRegionCode, 4);
    /*
    printf("reg_code\t= %c%c%c%c\t",
            psUnpack->sAddress.acRegionCode[0],
            psUnpack->sAddress.acRegionCode[1],
            psUnpack->sAddress.acRegionCode[2],
            psUnpack->sAddress.acRegionCode[3]);
            */
    printf("reg  = %s\t", str_reg);
    show_sub_name("区域码\n");

    printf("mst  = %d\t",    psUnpack->sAddress.ucMAddress);
    show_sub_name("主站地址\n");
    printf("tml  = %d\t",    psUnpack->sAddress.usTAddress);
    show_sub_name("终端地址\n");
    printf("team = %s\t",    psUnpack->sAddress.bTeamAddr == TRUE ? "true" : "flase");
    show_sub_name("是否为组地址\t");
    (psUnpack->sAddress.bTeamAddr == TRUE ) ? show_item_value("是") : show_item_value("否");

   
    

    
    // 应用层数据
    show_main_name("\n应用层数据:\n");
    nSubNum = psUnpack->ucCmdNum;
    printf("subNum = %d\t", nSubNum);
    show_sub_name("子命令个数\n");

    for(i = 0; i < nSubNum; i++)
    {
        //printf("app data %d\n", i+1);
        sprintf(strTmp, "\n-------------------------- %d -----------------------------\n", i+1);
        fm_print(strTmp, FR_GREEN|FM_BOLD);
        show_app_data_adp(eDir, &(psUnpack->sCmdData[i]));
        printf("\n\n");
        //fm_print(strTmp, FR_GREEN|FM_BOLD);
    }
    printf("\n");
}




void show_pack(smtPack *psUnpack)
{
    if(!psUnpack)
    {
        printf("psUnpack is null\n");
        return;
    }

   
    char *str = NULL;
    char str_reg[5] = {0};
    char strTmp[128] = {0};
    int i = 0;
    int nSubNum = 0;
    eMtDir eDir;

    // 输出地址信息
    show_main_name("address:\n");
    memcpy(str_reg,psUnpack->sAddress.acRegionCode, 4);
    /*
    printf("reg_code\t= %c%c%c%c\t",
            psUnpack->sAddress.acRegionCode[0],
            psUnpack->sAddress.acRegionCode[1],
            psUnpack->sAddress.acRegionCode[2],
            psUnpack->sAddress.acRegionCode[3]);
            */
    printf("reg  = %s\t", str_reg);
    show_sub_name("区域码\n");

    printf("mst  = %d\t",    psUnpack->sAddress.ucMAddress);
    show_sub_name("主站地址\n");
    printf("tml  = %d\t",    psUnpack->sAddress.usTAddress);
    show_sub_name("终端地址\n");
    printf("team = %s\t",    psUnpack->sAddress.bTeamAddr == TRUE ? "true" : "flase");
    show_sub_name("是否为组地址\t");
    (psUnpack->sAddress.bTeamAddr == TRUE ) ? show_item_value("是") : show_item_value("否");

    // 主功能码
    show_main_name("\nmain_code:\n");
    fm_print("AFN  = ",0);
    printf("%02X\t", psUnpack->eAFN);
    switch(psUnpack->eAFN)
    {
        case AFN_00_CONF:
            str = "确认否认";
            break;
        case AFN_01_RSET:
            str = "复位";
            break;
        case AFN_02_LINK:
            str = "接口检测";
            break;
        case AFN_03_RELY:
            str = "中继站命令";
            break;
        case AFN_04_SETP:
            str = "设置参数";
            break;
        case AFN_05_CTRL:
            str = "控制命令";
            break;
         case AFN_06_AUTH:
            str = "身份认证";
            break;
         case AFN_08_CASC:
            str = "请求被级联终端主动上报";
            break;
        case AFN_09_CFIG:
            str = "请求终端配置";
            break;
        case AFN_0A_GETP:
            str = "查询参数";
            break;
         case AFN_0B_ASKT:
            str = "请求任务数据";
            break;
         case AFN_0C_ASK1:
            str = "请求1类数据 实时数据";
            break;

        case AFN_0D_ASK2:
            str = "请求2类数据 历史数据";
            break;
        case AFN_0E_ASK3:
            str = "请求3类数据 事件数据";
            break;
         case AFN_0F_FILE:
            str = "文件传输";
            break;
         case AFN_10_DATA:
            str = "数据转发";
            break;

        default:
            str = "未知命令";
            break;

    }

    show_sub_name("主功能码\t");
    show_item_value(str);

    //控制域
    show_main_name("\nctrl_field:\n");
    printf("eDir = %d\t", psUnpack->eDir);
    eDir = psUnpack->eDir;
    switch(eDir)
    {
        case MT_DIR_UNKOWN:
            str = "未知报文方向";
            break;
        case MT_DIR_M2S:
            str = "从主到到集中器(下行)";
            break;
        case MT_DIR_S2M:
            str = "从集中器到主站(上行)";
            break;
        default:
            str = "未知报文方向";
            break;
    }
    
    show_sub_name("报文传输方向\t");
    show_item_value(str); 

    // ctrl erpm
    printf("\neRPM = %d\t", psUnpack->ePRM);
    switch(psUnpack->ePRM)
    {
        case MT_PRM_ACTIVE:
            str = "来自启动站";
            break;
        case MT_PRM_PASIVE:
            str = "来自从动站";
            break;
        default:
            str = "从主动站未知";
            break;
    }
    
    show_sub_name("报文来源\t");
    show_item_value(str); 
    printf("\n");

    // ucPFC 帧计数器
    show_main_name("ucSeq:\n");
    printf("ucSeq  = %d\t", psUnpack->ucSeq);
    show_sub_name("帧计数器\n"); 

    printf("ePos = %d\t", psUnpack->ePos);
    show_sub_name("位置类型\t"); 
    switch(psUnpack->ePos)
    {
        case MT_POS_SIGLE:
            show_item_value("单帧"); 
            printf("\n");
            break;
        case MT_POS_MUL_S:
            show_item_value("多帧起始帧");
            printf("\n"); 
            break;
        case MT_POS_MUL_M:
            show_item_value("多帧中间帧");
            printf("\n"); 
            break;
        case MT_POS_MUL_E:
            show_item_value("多帧最后帧");
            printf("\n"); 
            break;
    
        default:
            show_error("错误的帧类型");
            printf("\n"); 
            break;               
    }



    // 附加域
    show_main_name("aux_field:\n");
    // EC
    if(psUnpack->bEC == TRUE)
    {
        printf("bEC  = true\t");
        show_sub_name("事件计数器\t"); 
        show_item_value("有");
        printf("\n"); 
    }
    else
    {
        printf("bEC  = false\t");
        show_sub_name("事件计数器\t"); 
        show_item_value("无");
        printf("\n"); 
    }

    // pw
    if(psUnpack->bPW == TRUE)
    {
        printf("bPW  = true\t");
        show_sub_name("消息认证码\t"); 
        show_item_value("有");
        printf("\n"); 
    }
    else
    {
        printf("bPW  = false\t");
        show_sub_name("消息认证码\t"); 
        show_item_value("无");
        printf("\n"); 
    }

    //tp
    if(psUnpack->bTP == TRUE)
    {
        printf("bTP  = true\t");
        show_sub_name("时间标签\t"); 
        show_item_value("有");
        printf("\n"); 
    }
    else
    {
        printf("bTP  = false\t");
        show_sub_name("时间标签\t"); 
        show_item_value("无");
        printf("\n"); 
    }

    // show EC value
    if(psUnpack->bEC == TRUE)
    {
        show_main_name("EC:\n");
        printf("EC1  = %d\n",  psUnpack->sEC.ucEC1);
        printf("EC2  = %d\n",  psUnpack->sEC.ucEC2);
    }

    // show pw
    if(psUnpack->bPW == TRUE)
    {
        show_main_name("PW:\n");
        char apw[17] = {0};
        memcpy((void*)apw, psUnpack->acPW, 16);
        printf("aucPW = \t");
        for(i = 0; i < 16; i++)
        {
            printf("%02d ",apw[i]);
        }
        printf("\n");
        
    }

    // show tp
    if(psUnpack->bTP == TRUE)
    {
       show_main_name("TP:\n");
       printf("PFC  = %d\t", psUnpack->sTP.ucPFC);
       show_sub_name("启动帧帧序号计数器PFC\n"); 
       
       printf("PDM  = %d\t", psUnpack->sTP.ucPermitDelayMinutes);
       show_sub_name("允许发送传输延时时间\n");

       #if 1
       printf("ucDD = %d\n", psUnpack->sTP.sDDHHmmss.ucDD);
       printf("ucHH = %d\n", psUnpack->sTP.sDDHHmmss.ucHH);
       printf("ucmm = %d\n", psUnpack->sTP.sDDHHmmss.ucmm);
       printf("ucss = %d\t", psUnpack->sTP.sDDHHmmss.ucss);
  
       printf("%d", psUnpack->sTP.sDDHHmmss.ucDD);
       show_sub_name("日"); 
       printf("%d", psUnpack->sTP.sDDHHmmss.ucHH);
       show_sub_name("时"); 
       printf("%d", psUnpack->sTP.sDDHHmmss.ucmm);
       show_sub_name("分");
       printf("%d", psUnpack->sTP.sDDHHmmss.ucss);
       show_sub_name("秒\n"); 
        
       #endif
       
       
       #if 0
       printf("time  = \t");
       
       sprintf(str_reg,"%d", psUnpack->sTP.ucDD);
       show_item_value(str_reg);
       show_sub_name("日"); 
       
       sprintf(str_reg,"%d", psUnpack->sTP.ucHH);
       show_item_value(str_reg);
       show_sub_name("时"); 
       
       sprintf(str_reg, "%d", psUnpack->sTP.ucmm);
       show_item_value(str_reg);
       show_sub_name("分");
       
       sprintf(str_reg, "%d", psUnpack->sTP.ucss);
       show_item_value(str_reg);
       show_sub_name("秒\n"); 
       #endif
       
    }

    // 应用层数据
    show_main_name("app_data:\n");
    nSubNum = psUnpack->usDataNum;
    printf("subNum = %d\t", nSubNum);
    show_sub_name("子命令个数\n");

    for(i = 0; i < nSubNum; i++)
    {
        //printf("app data %d\n", i+1);
        sprintf(strTmp, "\n-------------------------- %d -----------------------------\n", i+1);
        fm_print(strTmp, FR_GREEN|FM_BOLD);
        show_app_data(eDir, &(psUnpack->sData[i]));
        printf("\n\n");
        //fm_print(strTmp, FR_GREEN|FM_BOLD);
    }
    printf("\n");
}

void test_unpack_adp(int nstart, int argc, char *argv[])
{
    INT32  i, j = 0;
    UINT16 usLen = argc - nstart  ;
    UINT8* pInBuf = NULL;
    sMtInit  sInit = {0};
   // printf("argc = %d , nstart = %d, usLen = %d------------",argc, nstart, usLen);
   printf("unpack len = %d\n", usLen);

    // 解决命令行输入的参数
    for(i = nstart; i < argc; i++)
    {
        g_ucInBuf[j++] = strtol(argv[i], NULL,16);
       // printf(" %02X", (unsigned int)strtol(argv[i], NULL,16));
    }

    pInBuf = (UINT8*)g_ucInBuf;

   // sCmPacket *psUnpack = (sCmPacket *)g_ucOutBuf;
   char OutBuf[1024] = {0};
    sCmPacket *psUnpack = (sCmPacket *)OutBuf;

    //printf_buffer_color((char*)pInBuf, usLen);

    // 协议初始化
    sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eMtInit(&sInit);
    
    //调用解析函数
    eMtErr eRet = ecm_3761_unpack(pInBuf, usLen, psUnpack);

    if(eRet != MT_OK)
    {
        printf("emtUnPack() error code = %d\n", eRet);
        show_mt_error(eRet);
    }
    else
    {
        fm_print("--------------------------unpack success-------------------------\n",FR_GREEN);
        // 显示解析结构
        show_pack_adp(psUnpack); 
        fm_print("--------------------------unpack success-------------------------\n",FR_GREEN);
    }
}



void unpack_analyse(int nstart, int argc, char *argv[])
{
    INT32  i, j = 0;
    UINT16 usLen = argc - nstart ;
    UINT8* pInBuf = NULL;
    eMtErr eRet = MT_OK;
    sMtInit  sInit = {0};
    sMtUnpackCommon sUnpackCommon;
    UINT8  ucTemp = 0;
    char buf[64] = {0};
    char *str = NULL;
    sMtCmdInfor    sCmdInfor   = {0};
    eMtDir eDir;

   
    for(i = nstart; i < argc; i++)
    {
        g_ucInBuf[j++] = strtol(argv[i], NULL,16);
    }

    pInBuf = (UINT8*)g_ucInBuf;

     // 协议初始化
    sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eMtInit(&sInit);

    // 
    eRet = emt_unpack_common(&sUnpackCommon,pInBuf, usLen);
    if(MT_OK != eRet)
    {
        printf("emt_unpack_common() error code = %d\n", eRet);
        return;
    }
    
    // 输出结果
    fm_print("--------------------------analyse success-------------------------\n",FR_GREEN);
    show_main_name("起始字符:\t");
    printf("    [%02X]\n", sUnpackCommon.sfComHead.f68);

    // L1   
    show_main_name("长 度 域:\t");
    show_sub_name(" L1:"); 
    printf("[%02X %02X]", (sUnpackCommon.sfComHead.p10 | (sUnpackCommon.sfComHead.L1 << 2)), sUnpackCommon.sfComHead.L2);
    printf("\t%d\t", sUnpackCommon.usLenUserField1);

    show_item_value("应用层");
    printf(" %d ", sUnpackCommon.usLenUserField1 - 6);
    show_item_value("控制域");
    printf(" 1 ");
    show_item_value("地址域");
    printf(" 5\n");
  
    // L2   
    show_sub_name("\t\t L2:");
    printf("[%02X %02X]\t", (sUnpackCommon.sfComHead.p10_2 | (sUnpackCommon.sfComHead.L1_2 << 2)), sUnpackCommon.sfComHead.L2_2);
    printf("%d\t", sUnpackCommon.usLenUserField2);
    show_item_value("应用层");
    printf(" %d ", sUnpackCommon.usLenUserField2 - 6);
    show_item_value("控制域");
    printf(" 1 ");
    show_item_value("地址域");
    printf(" 5\n");

    
    show_main_name("起始字符:\t");
    printf("    [%02X]\n", sUnpackCommon.sfComHead.s68);

    show_main_name("控 制 域:\t");
    show_sub_name("  C:");
    ucTemp = sUnpackCommon.sfComHead.C;
    printf("[%02X]\t", ucTemp);

    for(i = 7; i >= 0; i--)
    {
       printf("%d", (ucTemp >> i) & 0x01);
    }
    printf("\n");
    show_sub_name("\t\tDIR:\t\t");
    printf("%d\t",  ucTemp & 0x80 ? 1:0);
    BOOL bDown = ((ucTemp & 0x80) == 0 ? TRUE:FALSE);
    sprintf(buf, "%s\n", (ucTemp & 0x80) == 0 ? "下行":"上行");
    show_item_value(buf);

    // PRM
    show_sub_name("\t\tPRM:\t\t");
    printf("%d\t",  (ucTemp & 0x40) ? 1:0);
    BOOL bPRM = ((ucTemp & 0x40) ? TRUE:FALSE);
    sprintf(buf, "%s\n", (ucTemp & 0x40) == 0 ? "从动站":"启动站");
    show_item_value(buf);

    // FCB ACD
    if(bDown == TRUE)
    {   
        eDir = MT_DIR_M2S;
        // fcb
        show_sub_name("\t\tFCB:\t\t");
        printf("%d\t",  (ucTemp & 0x20) >> 5);
        show_item_value("服务的变化位\n");

        // fcv
        show_sub_name("\t\tFCV:\t\t");    
        printf("%d\t",  (ucTemp & 0x10) >> 4);
        if(((ucTemp & 0x10) >> 4) == 1)
        {
            show_item_value("FCB 位有效\n");
        }
        else
        {
            show_item_value("FCB 位无效\n");
        }
    }
    else
    {
        eDir = MT_DIR_S2M;

        show_sub_name("\t\tACD:\t");
        printf("%d\t",  (ucTemp & 0x20) >> 5);

        memset(buf, 0,64);
        if(((ucTemp & 0x20) >> 5) == 1)
        {
            sprintf(buf, "\t%s", "有事件\n");
        }
        else
        {
            sprintf(buf, "\t%s", "无事件\n");
        }

        show_item_value(buf);

    }

    // FNCODE
    show_sub_name("\t\tFNC:\t\t");
    ucTemp = ucTemp & 0xF;
    printf("%d\t",  ucTemp);
    memset(buf, 0,64);

    if(bPRM == FALSE)
    {
        switch(ucTemp)
        {
            case 0:
            sprintf(buf, "%s", "认可");
            break;     

            case 8:
            sprintf(buf, "%s", "用户数据");
            break; 

            case 9:
            sprintf(buf, "%s", "否认：无所召唤的数据");
            break; 

            case 11:
            sprintf(buf, "%s", "链路状态");
            break; 

            default:
            sprintf(buf, "%s", "未知功能码");

             break;
        }
        
    }
    else
    {
        switch(ucTemp)
        {
            case 1:
            sprintf(buf, "%s", "复位命令");
            break;     

            case 4:
            sprintf(buf, "%s", "用户数据");
            break; 

            case 9:
            sprintf(buf, "%s", "链路测试");
            break; 

            case 10:
            sprintf(buf, "%s", "请求1级数据");
            break; 

            case 11:
            sprintf(buf, "%s", "请求2级数据");
            break; 

            default:
            sprintf(buf, "%s", "未知功能码");
            break;
        }

    }

    show_item_value(buf);
    printf("\n");

    // address
    show_main_name("地 址 域:");
    show_sub_name("\t A1:");
    printf("[%02X %02X]\t\t", sUnpackCommon.sfComHead.A.acRegionCode[0], sUnpackCommon.sfComHead.A.acRegionCode[1]);
    show_item_value("行政区划码\n");

    show_sub_name("\t\t A2:");
    printf("[%02X %02X]\t", sUnpackCommon.sfComHead.A.acRegionCode[2], sUnpackCommon.sfComHead.A.acRegionCode[3]);

    printf("%d\t", sUnpackCommon.sComPack.sAddr.usTAddress);
    if(sUnpackCommon.sComPack.sAddr.usTAddress == 0)
    {
        show_item_value("集中器 无效地址");
    }
    else if(sUnpackCommon.sComPack.sAddr.usTAddress == 0xFFFF)
    {
        show_item_value("集中器 广播地址");
    }
    else
    {
        show_item_value("集中器地址");

    }
   
    show_sub_name("\n\t\t A3:");
    ucTemp = sUnpackCommon.sfComHead.A.acRegionCode[4];
    printf("[%02X]\t", ucTemp);
   
    printf("%d\t", sUnpackCommon.sComPack.sAddr.ucMAddress);
    show_item_value("主站地址\n");
    show_sub_name("\t\t bT:\t\t");
    ucTemp = ucTemp & 0x01;
    printf("%d\t", ucTemp);
    if(ucTemp == 1)
    {
        show_item_value("A2为组地址\n");
    }
    else
    {
        show_item_value("A2为单地址\n");
    }

    // AFN
    show_main_name("功能码域:");
    show_sub_name("\tAFN:");

    ucTemp = sUnpackCommon.sfComHead.A.acRegionCode[5];
    printf("[%02X]\t\t", ucTemp);

    eMtAFN eAfn = (eMtAFN)ucTemp;
    switch(ucTemp)
    {
        case AFN_00_CONF:
            str = "确认否认";
            break;
        case AFN_01_RSET:
            str = "复位";
            break;
        case AFN_02_LINK:
            str = "接口检测";
            break;
        case AFN_03_RELY:
            str = "中继站命令";
            break;
        case AFN_04_SETP:
            str = "设置参数";
            break;
        case AFN_05_CTRL:
            str = "控制命令";
            break;
         case AFN_06_AUTH:
            str = "身份认证";
            break;
         case AFN_08_CASC:
            str = "请求被级联终端主动上报";
            break;
        case AFN_09_CFIG:
            str = "请求终端配置";
            break;
        case AFN_0A_GETP:
            str = "查询参数";
            break;
         case AFN_0B_ASKT:
            str = "请求任务数据";
            break;
         case AFN_0C_ASK1:
            str = "请求1类数据 实时数据";
            break;

        case AFN_0D_ASK2:
            str = "请求2类数据 历史数据";
            break;
        case AFN_0E_ASK3:
            str = "请求3类数据 事件数据";
            break;
         case AFN_0F_FILE:
            str = "文件传输";
            break;
         case AFN_10_DATA:
            str = "数据转发";
            break;

        default:
            str = "未知命令";
            break;

    }
    show_item_value(str);

    // SEQ
    show_main_name("\n帧序列域:");
    show_sub_name("\tSEQ:");
    ucTemp = sUnpackCommon.sfComHead.A.acRegionCode[6];
    printf("[%02X]\t", ucTemp);

    for(i = 7; i >= 0; i--)
    {
       printf("%d", (ucTemp >> i) & 0x01);
    }
    printf("\n");
    show_sub_name("\t\tTpV:\t\t");
    printf("%d\t",  ucTemp & 0x80 ? 1:0);
    BOOL bTp = (ucTemp & 0x80) ? TRUE:FALSE;
    sprintf(buf, "%s\n", (bTp == TRUE) ? "有TP 6":"无TP 0");
    show_item_value(buf);

    // FIR
    UINT8 ucFIR = (ucTemp & 0x40) ? 1:0;
    show_sub_name("\t\tFIR:\t\t");
    printf("%d\n",  ucFIR);

    UINT8 ucFIN = (ucTemp & 0x40) ? 1:0;
    show_sub_name("\t\tFIN:\t\t");
    printf("%d\t", ucFIN);

    
    if(ucFIR == 0)
    {
        if(ucFIN == 0)
        {
            str = "多帧：中间帧";
        }
        else
        {
            str = "多帧：结束帧";
        }
    }
    else
    {
        if(ucFIN == 0)
        {
            str = "多帧：第1帧";
        }
        else
        {
            str = "单帧";
        }
        
    }
    
    show_item_value(str);

    // CON
    show_sub_name("\n\t\tCON:\t\t");
    BOOL bCon = (ucTemp & 0x10) ? TRUE : FALSE;
    printf("%d\t",  (ucTemp & 0x10) ? 1 : 0);
    if(bCon == TRUE)
    {
        show_item_value("需要确认");
    }
    else
    {
        show_item_value("不需要确认");
    }
    // CON
    show_sub_name("\n\t\tseq:\t\t");
    ucTemp = ucTemp & 0xF;
    printf("%d\t",  ucTemp);
 
    show_item_value("帧序号PSEQ/RSEQ\n");

    //第一个DaDt
    show_main_name("应用数据:");

    show_sub_name("\tCMD:");
    printf("[%02X %02X %02X %02X]\n", 
        sUnpackCommon.sComPack.pSeq2Cs[0],
        sUnpackCommon.sComPack.pSeq2Cs[1],
        sUnpackCommon.sComPack.pSeq2Cs[2],
        sUnpackCommon.sComPack.pSeq2Cs[3]);


    sMtDaDt sDaDt = {0};
    memcpy(&sDaDt, sUnpackCommon.sComPack.pSeq2Cs, sizeof(sMtDaDt));
    
    show_sub_name("\t\tDa1:\t\t");
    printf("%d\n",  sDaDt.ucDA1);
    show_sub_name("\t\tDa2:\t\t");
    printf("%d\n",  sDaDt.ucDA2);
    
    show_sub_name("\t\tDt1:\t\t");
    printf("%d\n",  sDaDt.ucDT1);
    show_sub_name("\t\tDt2:\t\t");
    printf("%d\n",  sDaDt.ucDT2);


    sMtPnFn sPnFn;
    eRet =  emt_dadt_to_pnfn(&sDaDt, &sPnFn);
    sMtCmdPn sCmdPn[64];
    UINT8    ucNumCmdPn = 0;
    if(eRet != MT_OK)
    {
        show_item_value("标识错误\n");
    }
    else
    {             
        eRet = emt_pnfn_to_cmdpn(eAfn, &sPnFn, 1,   (sMtCmdPn*)&sCmdPn, &ucNumCmdPn);

        for(i = 0; i < ucNumCmdPn; i++)
        {
             show_main_name("命令类型:");
            printf("\t%d:\n", i+1);
            show_sub_name("\t\tPn:\t\t");
            printf("%d\n",  sCmdPn[i].usPn);
            show_sub_name("\t\tcmd:\t\t");
            printf("%04X\t",  sCmdPn[i].eCmd);
            eRet = eMtGetCmdInfor(sCmdPn[i].eCmd, eDir, &sCmdInfor);
            if(MT_OK != eRet)
            {
               show_item_value("未知命令\n");
            }
            else
            {
               show_item_value(sCmdInfor.pName);
               printf("\n");
            }
        }
       
    }
    
   


    fm_print("--------------------------analyse success-------------------------\n",FR_GREEN);
}


void test_unpack(int nstart, int argc, char *argv[])
{
    INT32  i, j = 0;
    UINT16 usLen = argc - nstart ;
    UINT8* pInBuf = NULL;
    sMtInit  sInit = {0};

    // printf("\nargc = %d , nstart = %d, usLen = %d------------",argc, nstart, usLen);
    // 解决命令行输入的参数
    for(i = nstart; i < argc; i++)
    {
        g_ucInBuf[j++] = strtol(argv[i], NULL,16);
        //printf(" %02X", (unsigned int)strtol(argv[i], NULL,16));
    }


    pInBuf = (UINT8*)g_ucInBuf;


    
    //smtPack *psUnpack = (smtPack *)g_ucOutBuf;

    //smtPack *psUnpack = (smtPack *)malloc(BUF_LEN_MAX);
    smtPack *psUnpack = (smtPack *)malloc(5* 1024);
    //char buf[5*1024] = {0};
    
    //printf_buffer_color((char*)pInBuf, usLen);


    // 协议初始化
    sInit.eRole = MT_ROLE_CONTOR;
    sInit.ucPermitDelayMinutes = 255;
    eMtInit(&sInit);

    //调用解析函数
    eMtErr eRet = emtUnPack(psUnpack, pInBuf, usLen);

    if(eRet != MT_OK)
    {
        printf("emtUnPack() error code = %d\n", eRet);
        show_mt_error(eRet);
    }
    else
    {
        fm_print("--------------------------unpack success-------------------------\n",FR_GREEN);
        // 显示解析结构
        show_pack(psUnpack); 
        fm_print("--------------------------unpack success-------------------------\n",FR_GREEN);
       
    }
    
    free(psUnpack);
}


int main(int argc, char* argv[])
{
    
    //int opt = 0;  // 选项
    //int longIndex = 0;
    //char *strOpt = "uohcnmap:t:e:a:d:";
    //int    iTest= 0;// 测试例ID
    //struct option longOpts[] =
    //{
    //    {"address",     required_argument,    NULL,    'a'},
    //    {"pack",        required_argument,    NULL,    'p'},
    //    {"test",        required_argument,    NULL,    't'},
    //    {"down",        required_argument,    NULL,    'd'},
    //    {"error",       required_argument,    NULL,    'e'},
    //    {"adpack",      required_argument,    NULL,    'a'},
    //    {"help",        no_argument,          NULL,    'h'},
    //    {"unpack",      no_argument,          NULL,    'u'},
    //    {"oadp",        no_argument,          NULL,    'o'},
    //    {"modbus",      no_argument,          NULL,    'm'},
    //    {"nengxiao",    no_argument,          NULL,    'n'},
    //    {"all",         no_argument,          NULL,     0},
    //    {NULL,          no_argument,          NULL,     0}
    //};

    //while((opt = getopt_long(argc, argv,strOpt, longOpts, &longIndex)) != -1)
    //{
    //    switch(opt)
    //    {
    //        case 'h':
    //            {
    //               int len = sizeof(sMtAfn0dF218_f);

    //               printf("sMtAfn0dF218_f len = %d\n", len);
    //               len = sizeof(sMtTd_c_f);
    //               printf("sMtTd_c_f len = %d\n", len);

    //            }
    //              break;

    //        case 'a':
    //            unpack_analyse(optind, argc, argv);
    //            break;

    //        case 'd':
    //            iTest = (int)strtol(optarg, NULL, 16);
    //            printf("test id = %04X\n", iTest);
    //            test_pack_down(iTest);
    //            break;

    //        case 't':
    //            iTest = (int)strtol(optarg, NULL, 16);
    //            printf("test id = %04X\n", iTest);
    //            test_pack(iTest);
    //            break;

    //        case 'e':

    //            {
    //                int iErr = (int)strtol(optarg, NULL, 10);
    //                show_mt_error(iErr);
    //            }
    //          break;


    //        case 'u':
    //            test_unpack(optind, argc, argv);
    //            break;
    //        case 'o':
    //            test_unpack_adp(optind, argc, argv);
    //            break;

    //          default:
    //              printf("Your command line parameters are not right!\n");
    //            return -1;
    //    }
    //}
    //return 0;
    

    INT32  i, j = 0;
    UINT8* pInBuf = NULL;
    sMtInit  sInit = { 0 };
    
    // 十六进制字符串
    // char* arr[] = { "68" ,"D6" ,"00", "D6", "00", "68", "88" ,"00" ,"99" ,"49" ,"AE" ,"14", "09", "65" ,"00", "00" ,"01" ,"00" ,"54" ,"4F", "50", "53", "39", "39", "30" ,"30" ,"41" ,"45" ,"34" ,"39", "33" ,"2E" ,"33","30" ,"11", "04" ,"22" ,"46" ,"4D", "30", "30", "30", "30", "30", "31", "32", "38", "4D", "31", "33", "30", "31", "33", "2E", "30", "32", "16", "02", "17", "C3", "16" };

    // 0A_F150
     char* arr[] = {"68","32","08","32","08","68","88","00","99","49","AE","14","0A","64","00","00","20","12","00","00","FE","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","1F","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","C6","16"};

    // 0A_F604
    //char* arr[] = {"68","3A","00","3A","00","68","88","00","99","49","AE","14","0A","65","00","00","08","4B","01","07","F6","16"};

    // 0A_F606
    //char* arr[] = {"68","4A","00","4A","00","68","88","00","99","49","AE","14","0A","66","00","00","20","4B","07","69","87","00","00","00","FE","16"};

    // 0A_F607
    // char* arr[] = { "68","92","00","92","00","68","88","00","99","14","B0","14","0A","63","00","00","40","4B","00","FF","FF","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","EF","16" };

    // 0A_F609
    // char* arr[] = {"68","42","00","42","00","68","88","00","99","49","AE","14","0A","64","00","00","01","4C","70","01","00","00","58","16"};
    // char* arr[] = {"68","42","00","42","00","68","88","00","99","49","AE","14","0A","68","00","00","01","4C","70","01","00","00","5C","16"};

    // 0A F610
    // char* arr[] = {"68","4A","00","4A","00","68","88","00","99","49","AE","14","0A","68","00","00","02","4C","FE","01","00","00","00","00","EB","16"};

    // 0A F611
    // char* arr[] = { "68","B2","00","B2","00","68","88","00","99","14","B0","14","0A","6C","00","00","04","4C","0A","0A","14","64","0A","02","05","0F","0C","02","05","00","14","00","AA","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","3C","16" };
    // char* arr[] = { "68","B2","00","B2","00","68","88","00","99","14","B0","14","0A","6C","00","00","04","4C","0B","0A","14","64","0A","02","05","0F","0C","02","05","00","14","06","AA","D1","07","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","1B","16" };

    // 0A F612
    // char* arr[] = { "68","72","00","72","00","68","88","00","99","14","B0","14","0A","68","00","00","08","4C","00","01","00","00","10","00","00","20","00","50","01","00","50","00","00","05","96","16" };
    // char* arr[] = { "68","72","00","72","00","68","88","00","99","14","B0","14","0A","68","00","00","08","4C","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","AF","16" };

    // 0A F613
    //char* arr[] = { "68","3E","00","3E","00","68","88","00","99","49","AE","14","0A","61","00","00","10","4C","37","02","10","3C","16" };

    // 0A F615
    //char* arr[] = { "68","52","00","52","00","68","88","00","99","49","AE","14","0A","67","00","00","40","4C","00","50","00","00","00","50","00","00","C9","16" };

    // 0A F616
    // char* arr[] = { "68","3A","00","3A","00","68","88","00","99","14","B0","14","0A","69","00","00","80","4C","2C","01","65","16" };

    // 0A F617
    //char* arr[] = { "68","5E","00","5E","00","68","88","00","99","49","AE","14","0A","68","00","00","01","4D","00","06","00","00","05","00","50","01","05","05","0F","61","16" };

    // 0A F618
    // char* arr[] = { "68","72","00","72","00","68","88","00","99","14","B0","14","0A","61","00","00","02","4D","88","87","12","21","35","42","75","10","FF","FF","FF","FF","FF","FF","FF","FF","E9","16" };
    // char* arr[] = { "68","72","00","72","00","68","88","00","99","14","B0","14","0A","61","00","00","02","4D","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","A3","16" };

    // 0A F621
    // char* arr[] = {"68","6E","00","6E","00","68","88","00","99","14","B0","14","0A","6F","00","00","10","4D","30","00","02","00","02","00","30","00","05","FF","FF","FF","FF","FF","FF","32","16"};
    // char* arr[] = {"68","6E","00","6E","00","68","88","00","99","14","B0","14","0A","6F","00","00","10","4D","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","C0","16"};

    // 0A_F632
    // char* arr[] = {"68","76","00","76","00","68","88","00","99","49","AE","14","0A","69","00","00","80","4E","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","5C","16"};
     //char* arr[] = {"68","76","00","76","00","68","88","00","99","49","AE","14","0A","6F","00","00","80","4E","14","11","11","21","33","12","32","00","20","00","30","00","00","40","00","00","50","21","16"};
    // char* arr[] = {"68","76","00","76","00","68","88","00","99","49","AE","14","0A","63","00","00","80","4E","14","00","11","70","87","08","32","01","22","00","33","00","00","44","00","00","55","AC","16"};
    // char* arr[] = {"68","76","00","76","00","68","88","00","99","49","AE","14","0A","68","00","00","80","4E","14","98","99","92","21","75","32","07","54","07","54","06","07","54","06","07","54","83","16"};

    // 0C_F601
    //char* arr[] = { "68","82","00","82","00","68","88","00","99","49","AE","14","0C","E0","00","00","01","4B","01","00","00","00","00","01","02","03","01","01","02","00","03","05","00","20","31","16","20","00","FE","16" };

    // 0C F625
    //char* arr[] = {"68","3A","02","3A","02","68","88","00","99","49","AE","14","0C","A2","00","00","01","4E","46","00","09","0E","01","76","73","31","00","00","00","01","05","29","04","22","10","01","40","86","31","00","00","00","01","05","29","04","22","11","01","31","98","31","00","00","00","01","05","29","04","22","12","01","13","87","32","00","00","00","01","05","29","04","22","13","01","23","79","00","00","00","00","01","05","29","04","22","14","01","44","70","75","00","00","00","01","05","29","04","22","17","01","49","85","68","08","00","13","01","02","29","04","22","2A","01","78","13","80","00","00","13","01","08","29","04","22","2E","01","83","98","83","00","00","13","02","04","29","04","22","08","25","04","22","01","05","11","17","29","00","BB","16"};

    // 0C F602
    //char* arr[] = {"68","CE","00","CE","00","68","88","00","99","49","AE","14","0C","E7","01","01","02","4B","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","07","03","57","19","23","00","B9","16"};

    // 0C F604
     //char* arr[] = { "68","6A","0C","6A","0C","68","88","00","99","14","B0","14","0C","E5","00","00","08","4B","1A","00","44","03","19","06","A5","22","9B","FF","FF","FE","06","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","9B","FF","FF","FE","06","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","25","05","28","21","06","00","37","16" };

    //0C F625
    // char* arr[] = {"68","3A","02","3A","02","68","88","00","99","49","AE","14","0C","A2","00","00","01","4E","46","00","09","0E","01","76","73","31","00","00","00","01","05","29","04","22","10","01","40","86","31","00","00","00","01","05","29","04","22","11","01","31","98","31","00","00","00","01","05","29","04","22","12","01","13","87","32","00","00","00","01","05","29","04","22","13","01","23","79","00","00","00","00","01","05","29","04","22","14","01","44","70","75","00","00","00","01","05","29","04","22","17","01","49","85","68","08","00","13","01","02","29","04","22","2A","01","78","13","80","00","00","13","01","08","29","04","22","2E","01","83","98","83","00","00","13","02","04","29","04","22","08","25","04","22","01","05","11","17","29","00","BB","16"};
    //char* arr[] = {"68","4A","02","4A","02","68","88","00","99","49","AE","14","0C","A2","00","00","01","4E","46","00","09","0E","01","76","73","31","00","00","00","01","05","29","04","22","10","01","40","86","31","00","00","00","01","05","29","04","22","11","01","31","98","31","00","00","00","01","05","29","04","22","12","01","13","87","32","00","00","00","01","05","29","04","22","13","01","23","79","00","00","00","00","01","05","29","04","22","14","01","44","70","75","00","00","00","01","05","29","04","22","17","01","49","85","68","08","00","13","01","02","29","04","22","2A","01","78","13","80","00","00","13","02","08","29","04","22","05","21","04","22","2E","01","83","98","83","00","00","13","02","04","29","04","22","08","25","04","22","01","05","11","17","29","00","08","16"};

    // 0C_F627
    //char* arr[] = { "68","4A","04","4A","04","68","88","00","99","49","AE","14","0C","E8","00","00","04","4E","00","00","FE","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","FF","03","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","08","41","39","11","13","00","F6","16" };

    // 0C_F628
    //char* arr[] = { "68","4A","04","4A","04","68","88","00","99","49","AE","14","0C","E8","00","00","08","4E","00","00","DC","9F","DF","D7","E7","7E","BF","B9","FF","FF","1F","FF","7F","E9","53","D6","F1","B7","B7","18","5C","DC","BE","9B","2D","9D","FA","E1","F7","9D","FF","7B","F9","FE","FF","FF","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","08","41","39","11","13","00","87","16" };

    // 0C_F629
    //char* arr[] = { "68","CA","00","CA","00","68","88","00","99","49","AE","14","0C","E8","00","00","10","4E","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","21","01","00","00","00","00","EE","EE","EE","EE","EE","EE","08","41","39","11","13","00","72","16" };
    
    // 0C F633
    // char* arr[] = { "68","9A","00","9A","00","68","88","00","99","14","B0","14","0C","E9","01","01","01","4F","11","11","11","12","22","11","20","03","50","15","21","35","04","87","21","30","44","11","03","05","19","15","18","20","06","00","3B","16" };

    // 0C F639
    // char* arr[] = { "68","8E","00","8E","00","68","88","00","99","14","B0","14","0C","EA","01","01","40","4F","18","55","18","06","A5","22","15","54","18","06","A5","22","02","3F","00","00","00","1A","43","37","20","06","00","1B","16" };

    // 0C F640
    // char* arr[] = { "68","92","00","92","00","68","88","00","99","14","B0","14","0C","EC","01","01","80","4F","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","1C","07","39","20","06","00","00","16" };
    // char* arr[] = { "68","92","00","92","00","68","88","00","99","14","B0","14","0C","EC","01","01","80","4F","31","50","21","17","03","22","50","24","07","22","06","21","59","59","23","12","01","22","1C","07","39","20","06","00","F0","16" };

    // 0C_F641
    // char* arr[] = {"68","52","01","52","01","68","88","00","99","49","AE","14","0C","E1","08","03","01","50","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","11","58","31","21","05","00","91","16"};
    // char* arr[] = {"68","52","01","52","01","68","88","00","99","14","B0","14","0C","E1","01","01","01","50","33","58","05","02","25","22","00","00","00","31","12","22","59","59","23","31","12","22","99","99","99","99","99","00","06","00","00","00","00","06","00","00","00","00","06","00","00","00","00","10","07","06","05","02","00","00","00","01","01","01","05","06","00","00","00","00","06","00","00","00","00","06","00","00","00","00","21","21","43","21","05","00","A9","16"};

    // 0C_F642
    // char* arr[] = {"68","92","00","92","00","68","88","00","99","49","AE","14","0C","E3","01","01","02","50","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","13","52","33","21","05","00","E9","16"};
    // char* arr[] = {"68","92","00","92","00","68","88","00","99","49","AE","14","0C","E3","01","01","02","50","59","59","23","31","12","22","59","59","23","31","12","22","17","13","11","21","12","22","13","52","33","21","05","00","31","16"};

    // 0C_F643
    // char* arr[] = {"68","92","00","92","00","68","88","00","99","49","AE","14","0C","E5","01","01","04","50","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","15","35","34","21","05","00","D3","16"};
    // char* arr[] = {"68","92","00","92","00","68","88","00","99","49","AE","14","0C","E5","01","01","04","50","59","59","23","31","12","22","59","59","23","31","12","22","17","13","11","21","12","22","13","52","33","21","05","00","35","16"};

    // 0C_F644
    // char* arr[] = {"68","92","00","92","00","68","88","00","99","49","AE","14","0C","E6","01","01","08","50","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","16","35","35","21","05","00","DA","16"};
    // char* arr[] = {"68","92","00","92","00","68","88","00","99","49","AE","14","0C","E6","01","01","08","50","59","59","23","31","12","22","59","59","23","31","12","22","17","13","11","21","12","22","13","52","33","21","05","00","3A","16"};
    
    // 0C_F645  
    // char* arr[] = {"68","4E","00","4E","00","68","88","00","99","49","AE","14","0C","E7","01","01","10","50","00","17","31","37","21","05","00","26","16"};
    // char* arr[] = {"68","7E","00","7E","00","68","88","00","99","49","AE","14","0C","E7","01","01","10","50","01","17","31","37","17","31","37","17","31","37","17","31","37","17","31","37","21","05","00","23","16"};
    // char* arr[] = {"68","AE","00","AE","00","68","88","00","99","49","AE","14","0C","E7","01","01","10","50","02","01","01","41","20","21","70","59","59","23","31","12","22","21","87","32","09","68","12","31","40","09","30","11","22","17","31","37","21","05","00","90","16"};


    // 0C_F646  
    // char* arr[] = {"68","4E","00","4E","00","68","88","00","99","49","AE","14","0C","EA","01","01","20","50","00","1A","47","38","21","05","00","53","16"};
    // char* arr[] = {"68","7E","00","7E","00","68","88","00","99","49","AE","14","0C","EA","01","01","20","50","01","17","31","37","17","31","37","17","31","37","17","31","37","1A","47","38","21","05","00","50","16"};
    // char* arr[] = {"68","AE","00","AE","00","68","88","00","99","49","AE","14","0C","EA","01","01","20","50","02","01","01","41","20","21","70","59","59","23","31","12","22","21","87","32","09","68","12","31","40","09","30","11","22","1A","47","38","21","05","00","BD","16"};

    // 0C_F647  
    // char* arr[] = {"68","42","02","42","02","68","88","00","99","49","AE","14","0C","EB","01","01","40","50","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","1B","31","39","21","05","00","84","16"};
    // char* arr[] = {"68","42","02","42","02","68","88","00","99","49","AE","14","0C","EB","01","01","40","50","59","59","23","31","12","22","59","59","23","31","12","22","59","59","23","31","12","22","59","59","23","31","11","21","40","50","23","31","11","21","40","12","03","30","10","21","40","12","03","10","06","22","39","17","03","10","06","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","39","17","03","10","07","22","1B","31","39","21","05","00","46","16"};

    // 0C_F648  --无内容

    // 0C_F649
    // char* arr[] = {"68","D2","00","D2","00","68","88","00","99","49","AE","14","0C","EC","01","01","01","51","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","1C","06","40","21","05","00","9C","16"};
    // char* arr[] = {"68","D2","00","D2","00","68","88","00","99","49","AE","14","0C","EC","01","01","01","51","59","59","23","31","12","22","59","59","23","31","12","22","98","23","10","54","98","23","10","54","01","00","09","01","01","23","31","12","22","98","23","10","54","98","1C","06","40","21","05","00","FD","16"};

    // 0C_F650
    // char* arr[] = {"68","D2","00","D2","00","68","88","00","99","49","AE","14","0C","ED","01","01","02","51","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","1D","23","41","21","05","00","BD","16"};
    // char* arr[] = {"68","D2","00","D2","00","68","88","00","99","49","AE","14","0C","ED","01","01","02","51","59","59","23","31","12","22","59","59","23","31","12","22","98","23","10","54","98","23","10","54","01","00","09","01","01","23","31","12","22","98","23","10","54","98","1D","23","41","21","05","00","1E","16"};

    // 0C_F651  
    // char* arr[] = {"68","D2","00","D2","00","68","88","00","99","49","AE","14","0C","EE","01","01","04","51","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","1E","58","41","21","05","00","F6","16"};
    // char* arr[] = {"68","D2","00","D2","00","68","88","00","99","49","AE","14","0C","EE","01","01","04","51","59","59","23","31","12","22","59","59","23","31","12","22","98","23","10","54","98","23","10","54","01","00","09","01","01","23","31","12","22","98","23","10","54","98","1E","58","41","21","05","00","57","16"};

    // 0D F161  
    //char* arr[] = {"68","D2","00","D2","00","68","88","00","99","49","AE","14","0D","E0","04","03","01","14","18","04","22","00","00","00","00","00","04","00","57","71","55","03","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","10","34","54","09","19","00","E9","16"};

    // 0C F634
    //char* arr[] = { "68","4E","00","4E","00","68","88","00","99","49","AE","14","0C","E5","01","01","02","4F","00","25","23","50","18","29","00","49","16" };
    //char* arr[] = { "68","7E","00","7E","00","68","88","00","99","49","AE","14","0C","E5","01","01","02","4F","01","11","11","11","11","11","11","11","11","11","11","11","11","25","23","50","18","29","00","16","16" };

    // 0C F635
    //char* arr[] = {"68","5A","00","5A","00","68","88","00","99","49","AE","14","0C","ED","01","01","04","4F","01","01","01","00","0D","19","48","16","26","00","27","16"};
    //char* arr[] = { "68","8A","00","8A","00","68","88","00","99","49","AE","14","0C","ED","01","01","04","4F","01","01","01","12","11","11","11","11","11","11","11","11","11","11","11","11","0D","19","48","16","26","00","05","16" };
    //char* arr[] = { "68","BA","00","BA","00","68","88","00","99","49","AE","14","0C","ED","01","01","04","4F","01","01","01","02","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","11","0D","19","48","16","26","00","C1","16" };
    
    // 0D_F625
    // char* arr[] = {"68","3A","0A","3A","0A","68","88","00","99","49","AE","14","0D","ED","01","01","01","4E","05","05","22","3F","00","3F","13","00","74","10","62","00","00","00","01","05","17","00","49","33","32","00","00","00","01","05","20","00","18","35","32","00","00","00","01","05","23","00","82","55","32","00","00","00","01","05","28","00","10","35","32","00","00","00","01","05","2C","00","12","58","32","00","00","00","01","05","2E","00","50","30","31","00","00","00","01","05","36","00","03","35","31","00","00","00","01","05","3C","00","75","80","32","00","00","00","01","05","3E","00","86","73","31","00","00","00","01","05","40","00","69","02","32","00","00","00","01","05","43","00","82","30","32","00","00","00","01","05","45","00","76","21","32","00","00","00","01","05","47","00","04","71","31","00","00","00","01","05","4A","00","01","71","31","00","00","00","01","05","4D","00","38","94","31","00","00","00","01","05","4F","00","79","80","32","00","00","00","01","05","57","00","96","76","32","00","00","00","01","05","5C","00","47","14","31","00","00","00","01","05","5E","00","15","87","32","00","00","00","01","05","61","00","25","33","32","00","00","00","01","05","68","00","28","33","31","00","00","00","01","05","6C","00","30","57","32","00","00","00","01","05","6D","00","42","14","31","00","00","00","01","05","71","00","03","71","31","00","00","00","01","01","74","00","26","00","32","00","00","00","01","05","7A","00","29","62","32","00","00","00","01","05","7E","00","14","18","32","00","00","00","01","05","80","00","03","91","31","00","00","00","01","05","84","00","15","18","32","00","00","00","01","05","88","00","72","80","32","00","00","00","01","05","8A","00","12","30","32","00","00","00","01","05","8E","00","43","14","31","00","00","00","01","05","91","00","26","98","31","00","00","00","01","05","93","00","75","02","32","00","00","00","01","05","94","00","09","71","31","00","00","00","01","05","95","00","86","21","31","00","00","00","01","05","99","00","35","92","32","00","00","00","01","05","9D","00","05","21","31","00","00","00","01","05","9F","00","39","40","32","00","00","00","01","05","A1","00","90","47","32","00","00","00","01","05","AF","00","10","71","31","00","00","00","01","05","B9","00","51","33","32","00","00","00","01","05","CA","00","20","94","31","00","00","00","01","05","CB","00","99","92","31","00","00","00","01","05","CD","00","19","33","32","00","00","00","01","02","CE","00","39","41","32","00","00","00","01","05","D6","00","94","13","31","00","00","00","01","05","DC","00","76","80","32","00","00","00","01","05","E5","00","23","94","31","00","00","00","01","05","FB","00","75","55","32","00","00","00","01","05","FE","00","09","87","32","00","00","00","01","05","06","01","77","80","32","00","00","00","01","05","08","01","34","57","32","00","00","00","01","05","09","01","13","20","31","00","00","00","01","05","0A","01","27","33","32","00","00","00","01","05","0E","01","76","73","31","00","00","00","01","05","10","01","40","86","31","00","00","00","01","05","11","01","31","98","31","00","00","00","01","05","12","01","13","87","32","00","00","00","01","05","13","01","23","79","00","00","00","00","01","05","14","01","44","70","75","00","00","00","01","05","2E","01","83","98","83","00","00","13","01","04","4D","21","42","15","06","00","2D","16"};
    // char* arr[] = {"68","3A","0A","3A","0A","68","88","00","99","49","AE","14","0D","E1","01","01","01","4E","05","05","22","3F","00","3F","13","00","74","10","62","00","00","00","01","05","17","00","49","33","32","00","00","00","01","05","20","00","18","35","32","00","00","00","01","05","23","00","82","55","32","00","00","00","01","05","28","00","10","35","32","00","00","00","01","05","2C","00","12","58","32","00","00","00","01","05","2E","00","50","30","31","00","00","00","01","05","36","00","03","35","31","00","00","00","01","05","3C","00","75","80","32","00","00","00","01","05","3E","00","86","73","31","00","00","00","01","05","40","00","69","02","32","00","00","00","01","05","43","00","82","30","32","00","00","00","01","05","45","00","76","21","32","00","00","00","01","05","47","00","04","71","31","00","00","00","01","05","4A","00","01","71","31","00","00","00","01","05","4D","00","38","94","31","00","00","00","01","05","4F","00","79","80","32","00","00","00","01","05","57","00","96","76","32","00","00","00","01","05","5C","00","47","14","31","00","00","00","01","05","5E","00","15","87","32","00","00","00","01","05","61","00","25","33","32","00","00","00","01","05","68","00","28","33","31","00","00","00","01","05","6C","00","30","57","32","00","00","00","01","05","6D","00","42","14","31","00","00","00","01","05","71","00","03","71","31","00","00","00","01","01","74","00","26","00","32","00","00","00","01","05","7A","00","29","62","32","00","00","00","01","05","7E","00","14","18","32","00","00","00","01","05","80","00","03","91","31","00","00","00","01","05","84","00","15","18","32","00","00","00","01","05","88","00","72","80","32","00","00","00","01","05","8A","00","12","30","32","00","00","00","01","05","8E","00","43","14","31","00","00","00","01","05","91","00","26","98","31","00","00","00","01","05","93","00","75","02","32","00","00","00","01","05","94","00","09","71","31","00","00","00","01","05","95","00","86","21","31","00","00","00","01","05","99","00","35","92","32","00","00","00","01","05","9D","00","05","21","31","00","00","00","01","05","9F","00","39","40","32","00","00","00","01","05","A1","00","90","47","32","00","00","00","01","05","AF","00","10","71","31","00","00","00","01","05","B9","00","51","33","32","00","00","00","01","05","CA","00","20","94","31","00","00","00","01","05","CB","00","99","92","31","00","00","00","01","05","CD","00","19","33","32","00","00","00","01","02","CE","00","39","41","32","00","00","00","01","05","D6","00","94","13","31","00","00","00","01","05","DC","00","76","80","32","00","00","00","01","05","E5","00","23","94","31","00","00","00","01","05","FB","00","75","55","32","00","00","00","01","05","FE","00","09","87","32","00","00","00","01","05","06","01","77","80","32","00","00","00","01","05","08","01","34","57","32","00","00","00","01","05","09","01","13","20","31","00","00","00","01","05","0A","01","27","33","32","00","00","00","01","05","0E","01","76","73","31","00","00","00","01","05","10","01","40","86","31","00","00","00","01","05","11","01","31","98","31","00","00","00","01","05","12","01","13","87","32","00","00","00","01","05","13","01","23","79","00","00","00","00","01","05","14","01","44","70","75","00","00","00","01","05","2E","01","83","98","83","00","00","13","01","04","51","59","49","16","06","00","65","16"};
    
    // 0D_F632
    // char* arr[] = {"68","62","00","62","00","68","88","00","99","49","AE","14","0D","E1","01","01","80","4E","28","04","22","00","00","00","01","33","12","21","29","00","C8","16"};
    // char* arr[] = {"68","AA","00","AA","00","68","88","00","99","49","AE","14","0D","E8","01","01","80","4E","05","05","22","04","00","02","01","00","AA","AA","AA","AA","AA","AA","01","02","00","AA","AA","AA","AA","AA","AA","01","48","01","01","15","06","00","85","16"};
    // char* arr[] = { "68","AA","00","AA","00","68","88","00","99","49","AE","14","0D","E0","01","01","80","4E","06","05","22","02","00","02","24","00","55","08","31","00","00","00","06","11","01","31","98","31","00","00","00","06","00","32","03","14","07","00","34","16" };
    
    // 0D_F633
    // char* arr[] = {"68","A6","00","A6","00","68","88","00","99","49","AE","14","0D","E0","01","01","01","4F","05","05","22","EE","EE","EE","EE","EE","EE","00","00","00","00","00","00","00","00","00","00","00","00","00","00","50","54","19","16","06","00","04","16"};
    // char* arr[] = {"68","A6","00","A6","00","68","88","00","99","49","AE","14","0D","E0","01","01","01","4F","05","05","22","59","59","23","31","12","22","10","20","31","45","41","12","32","AE","8A","31","1B","00","00","00","50","54","19","16","06","00","59","16"};
    
    // 0D_F634
    // char* arr[] = {"68","5A","00","5A","00","68","88","00","99","49","AE","14","0D","E2","01","01","02","4F","05","05","22","00","52","24","50","19","06","00","7F","16"};
    // char* arr[] = {"68","BA","00","BA","00","68","88","00","99","49","AE","14","0D","E2","01","01","02","4F","05","05","22","02","11","22","33","44","55","16","51","04","05","06","A5","22","01","21","13","03","98","01","51","04","15","12","A5","22","52","24","50","19","06","00","D1","16"};
    
    // 0D_F635
    // char* arr[]= {"68","96","00","96","00","68","88","00","99","49","AE","14","0D","EB","01","01","04","4F","05","05","22","01","00","00","01","51","04","05","06","A5","22","51","04","05","06","A5","22","5B","01","08","21","06","00","80","16"};
    
    // 0D_F639
    // char* arr[] = {"68","9A","00","9A","00","68","88","00","99","49","AE","14","0D","EC","01","01","40","4F","05","05","22","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","5C","30","23","21","06","00","86","16"};
    // char* arr[] = {"68","9A","00","9A","00","68","88","00","99","49","AE","14","0D","EC","01","01","40","4F","05","05","22","59","59","23","31","12","22","59","59","23","31","12","22","02","10","00","00","00","00","30","23","21","06","00","E2","16"};
    
    // 0D_F652
    // char* arr[] = {"68","AA","00","AA","00","68","88","00","99","49","AE","14","0D","EC","01","01","08","51","05","05","22","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","EE","00","30","23","21","06","00","AC","16"};
    // char* arr[] = {"68","AA","00","AA","00","68","88","00","99","49","AE","14","0D","EC","01","01","08","51","05","05","22","02","00","00","01","00","00","10","00","00","59","59","23","31","12","22","59","59","23","31","12","22","00","30","23","21","06","00","AD","16"};

    // 0D_F653
    //错误检测
    // char* arr[] = {"68","DE","02","DE","02","68","88","00","99","49","AE","14","0D","EC","01","01","10","51","05","05","22","02","00","00","01","00","00","05","60","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","2B","16"};
    //5次
    // char* arr[] = {"68","DE","02","DE","02","68","88","00","99","49","AE","14","0D","EC","01","01","10","51","05","05","22","02","00","00","01","00","00","05","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","24","16"};
    //4次
    // char* arr[] = {"68","62","02","62","02","68","88","00","99","49","AE","14","0D","EC","01","01","10","51","05","05","22","02","00","00","01","00","00","04","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","8D","16"};

    // 0D_F654
    //错误检测
    // char* arr[] = {"68","DE","02","DE","02","68","88","00","99","49","AE","14","0D","EC","01","01","20","51","05","05","22","02","00","00","01","00","00","05","60","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","3B","16"};
    //5次
    // char* arr[] = {"68","DE","02","DE","02","68","88","00","99","49","AE","14","0D","EC","01","01","20","51","05","05","22","02","00","00","01","00","00","05","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","34","16"};
    //4次
    // char* arr[] = {"68","62","02","62","02","68","88","00","99","49","AE","14","0D","EC","01","01","20","51","05","05","22","02","00","00","01","00","00","04","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","9D","16"};

    // 0D_F655
    //错误检测
    // char* arr[] = {"68","DE","02","DE","02","68","88","00","99","49","AE","14","0D","EC","01","01","40","51","05","05","22","02","00","00","01","00","00","05","60","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","5B","16"};
    //5次
    // char* arr[] = {"68","DE","02","DE","02","68","88","00","99","49","AE","14","0D","EC","01","01","40","51","05","05","22","02","00","00","01","00","00","05","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","54","16"};
    //4次
    // char* arr[] = {"68","62","02","62","02","68","88","00","99","49","AE","14","0D","EC","01","01","40","51","05","05","22","02","00","00","01","00","00","04","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","59","59","23","31","11","22","00","04","05","07","50","14","15","16","01","09","11","26","51","04","85","06","21","21","21","59","59","23","31","12","22","00","30","23","21","06","00","BD","16"};


    
    int length = sizeof(arr) / sizeof(arr[0]);
    UINT16 usLen = length;
    printf("\n\n帧数据：");
    for (i = 0; i < length; i++)
    {
        g_ucInBuf[j++] = strtol(arr[i], NULL, 16);
        if (i == length - 1) {
            printf("%s", arr[i]);
        }
        else {
            printf("%s,", arr[i]);
        }

        //printf(" %02X", (unsigned int)strtol(argv[i], NULL,16));
    }
    printf("\n\n");
    pInBuf = (UINT8*)g_ucInBuf;




    //smtPack *psUnpack = (smtPack *)g_ucOutBuf;

    //smtPack *psUnpack = (smtPack *)malloc(BUF_LEN_MAX);
    smtPack* psUnpack = (smtPack*)malloc(10 * 1024);
    //char buf[5*1024] = {0};

    //printf_buffer_color((char*)pInBuf, usLen);


    // 协议初始化
    sInit.eRole = MT_ROLE_CONTOR;  
    sInit.ucPermitDelayMinutes = 255;
    eMtInit(&sInit);

    //调用解析函数
    eMtErr eRet = emtUnPack(psUnpack, pInBuf, usLen);

    if (eRet != MT_OK)
    {
        printf("emtUnPack() error code = %d\n", eRet);
        show_mt_error(eRet);
    }

    else
    {
        fm_print("---------------------------------------------------------------------------------------\n", FR_GREEN);
        fm_print("---------------------------------| unpack success |------------------------------------\n", FR_GREEN);
        fm_print("---------------------------------------------------------------------------------------\n", FR_GREEN);
        show_pack(psUnpack);        // 显示解析结构
        fm_print("---------------------------------------------------------------------------------------\n", FR_GREEN);
        fm_print("---------------------------------| unpack success |------------------------------------\n", FR_GREEN);
        fm_print("---------------------------------------------------------------------------------------\n", FR_GREEN);

    }
    free(psUnpack);

}






